wassup
wassup

Reputation: 2511

Static import - Netbeans error

The error, Netbeans gives me, is:

static import only from classes and interfaces

which is somehow strange for me, as this:

import org.lwjgl.opengl.GL11;

works fine while this:

import static org.lwjgl.opengl.GL11;

doesn't. Why is it not working for me?

BTW, GL11 is a class and I don't know why but Netbeans, when importing statically, thinks opengl is the class I want to import.

Upvotes: 0

Views: 2231

Answers (2)

Andrea Bergia
Andrea Bergia

Reputation: 5552

You wanna write:

import static org.lwjgl.opengl.GL11.*;

You are importing the members of the class, thus the * at the end.

Upvotes: 3

AlexR
AlexR

Reputation: 115378

Static import allows you to import static fields of other class. For example you can say

import static java.awt.Color.RED;

And then use RED in your class without mentioning class where it is defined.

Upvotes: 1

Related Questions