0
Static code doesn't work for me in Java
I am pretty sure that I have done something similar in the Static lesson, but I always get errors. public class Program { public class Landmark { public static int DEPTH; // String recordNo = "a"; // public String getRecordNo() { // return recordNo; // } // public void setRecordNo(String a){ // this.recordNo = a; // return a; // } Landmark(){ DEPTH--; } } public static void main(String[] args) { System.out.println("Hello World!"); Landmark.DEPTH = 0; Landmark k = new Landmark(); Landmark l = new Landmark(); System.out.println(Landmark.DEPTH); } }
2 Respostas
+ 2
move the landmark class outside of the program class
inner classes cant declare static variables unless they are also constant(i think)
0
Write the question related to your problem and I will surely solved it.