Hi All,
in the below code can any one please tell me
class x
{
String s="str";
}
class y extends x{
s="str1"; //1
public void show(){ s="str1"; // 2}
public static void main(String... args){
System.out.println("new y().s " + new y().s);
}
}
why the inherited variable s at line 1 will give
y.java:9: <identifier> xpected
s="str1"; compile time error and when the same statement is placed at line 2 it compiles fine does it mean any variables that are inherited from super class cant be put out side the functions in the subsclass.
Thanks