/**
* This code is from the book:
* Winder, R and Roberts, G (1998)
* Developing Java Software
* John Wiley & Sons.
* It is copyright (c) 1997 Russel Winder
* and Graham Roberts.
*/
class l1ClStat2{//Static2
public static void g(final int i){
System.out.println("In static void g(i = " +
i + ")");
}
public static void f(){
System.out.println("In static void f()");
g(10);
// Cannot call an instance method here
// without an object
// test(); // Error!
}
// instance method calling class method
public void test(){
g(5);
}
public static void main(String args[]){
f();
g(10);
// Create an instance object
l1ClStat2 s2 = new l1ClStat2();
s2.f(); // Note - can do this.
s2.test();
}
}
/******** sample compilation & run ********
# javac l1ClStat2.java
# java l1ClStat2
In static void f()
In static void g(i = 10)
In static void g(i = 10)
In static void f()
In static void g(i = 10)
In static void g(i = 5)
#
******************************************/