Ex:
static final int COMPANY_ID = 57575;
static final private int COMAPNY_ID = 52525;
Sample Program:
Case: We will define a constant and then used it straight away.
public class Constants
{
static final int COMPANY_ID = 56644;
public static void main(String[] args)
{
System.out.println("Company ID is: " + COMPANY_ID);
anotherMethod();
}
public static void anotherMethod()
{
System.out.println("Company ID is: " + COMPANY_ID);
}
}
The output is:
No comments:
Post a Comment