I am a beginner and I am trying to inherit the value of a variable in another class.The Value I get is 0 which is should be 10.
First class:
public class assignment
{
int var = 10;
public static void main(String[]args)
{
initialize pere = new initialize();
System.out.println(" ");
System.out.println(" pere.invariable: "+pere.invariable);
}
}
Second Class inherits var from class assignment:
public class initialize
{
public static int invariable;
public static void main(String[]args)
{
assignment variable = new assignment();
System.out.println(" variable.var : " + variable.var);
invariable = variable.var;
System.out.println(" invariable: " + invariable);
}
}
Why is pere.invariable = 0
and yet I have inherited invariable(in 2nd class) which is = 10?