(a) Doesn't your Java book tell you?
(b) A "public static" method is both public and static. A method that
is "public" but not "static" is public but not static.
--
"Based on their behaviour so far -- I have no idea." /Sahara/
Hewlett-Packard Limited registered no:
registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England
public class TestStatic {
int value;
public TestStatic(int v) {
value = v;
}
public int getCubeCalue() {
return value * value *value;
}
public static int getSquareValue(int i) {
return i * i;
}
public static void main(String[] args ) {
int i = 5;
TestStatic test = new TestStatic(i);
// in calling the getCubeCalue I did use test
// (instance of TestStatic)
// for invoking non static methods.
System.out.println("Cube value of " + i
+ " = " + test.getCubeCalue());
i = 10;
// in calling the getSquareValue I did not use test
// (instance of TestStatic)
System.out.println("Square value of " +
" = " + TestStatic.getSquareValue(i));
}
}