|
Use globally defined constants |
|
|
You can use globally defined constants by defining them inside a class and referencing themwithout instantiation.
public class CONSTANT {
public static final integer SUCCESS = 1;
public static final integer FAILURE = -1;
public static final integer NOTFOUND = 0;
}
|
Since the members of the class are defined as "static", there is no need to instantiate the class. To use a constant, simply use CONSTANT.[constant name]
if (myMethod()==CONSTANT.SUCCESS) {
...;
}
else {
...;
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.