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); } }

9th Sep 2017, 3:31 PM
Guglix
Guglix - avatar
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)
9th Sep 2017, 3:50 PM
Enzo
Enzo - avatar
0
Write the question related to your problem and I will surely solved it.
9th Sep 2017, 3:49 PM
Irwin Lopez
Irwin Lopez - avatar