0
Doubt
Can anyone say wt is wrong in execution https://code.sololearn.com/cu5suyLW71zi/?ref=app
1 Odpowiedź
+ 5
Haritha Vuppula index is not a static variable so you can't access directly with class. Call by object myApp.
And in constructor you need to write.
this.index = index;
If you will not do output will be 1
-----------------------------
class Super1 {
public int index = 1;
}
class App extends Super1{
public App(int index) {
this.index = index;
}
public static void main(String args[]) {
App myApp = new App(10);
System.out.println(myApp.index);
}
}