I need an explanation for 3,4,5 th rows. Whether it's a method or something. Can anyone please explain me clearly | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I need an explanation for 3,4,5 th rows. Whether it's a method or something. Can anyone please explain me clearly

public class Counter { public static int COUNT=0; Counter() { COUNT++; } } public class MyClass { public static void main(String[ ] args) { Counter c1 = new Counter(); Counter c2 = new Counter(); System.out.println(Counter.COUNT); } }

13th Mar 2018, 4:38 AM
Marana Coder
Marana Coder - avatar
1 Answer
0
Counter (){ COUNT++ } Is it a method? or Class
13th Mar 2018, 5:50 AM
Marana Coder
Marana Coder - avatar