Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Static



Why the following code requires xMethdod to be declared Static? xMethod is a member of Test.

public class Test {
public static void main(String[] args) {
int n = 2;
xMethod(n);

System.out.println("n is " + n);
}

void xMethod(int n) {
n++;
}
}