| Real'sHowTo |
|
|
Custom Search
|
| Real'sHowTo |
|
|
Custom Search
|
public class CONSTANT {
public static final integer SUCCESS = 1;
public static final integer FAILURE = -1;
public static final integer NOTFOUND = 0;
}if (myMethod()==CONSTANT.SUCCESS) {
...;
}
else {
...;
}public interface APPCONSTANT {
public static final String APPNAME = "The Super APP";
public static final String APPVERSION = "version 1.0";
public static final String DBDRIVER = "oracle.jdbc.driver.OracleDriver";
}
public class TheAppFrame extends Frame
implements APPCONSTANT {
TheAppFrame {
...
setTitle(APPNAME);
...
}
...
}NOTE: By convention, constant name are always in CAPITALS.
JDK1.5
JDK1.5 import statement can be used to import only static member from a class.
import static java.lang.Math.*;
public class DemoImport {
public static void main(String[] args) {
double x = 16.0;
System.out.println(abs(x));
System.out.println(PI);
// instead of System.out.println(Math.abs(x));
// System.out.println(Math.PI);
}
}
Written and compiled by Réal Gagnon ©1998-2013
[ home ]