Inheritance question
Can I ask a simple question, if I may?
Suppose I have a Class A like this:
public class A {
private static int x;
public static void process( ){
//do some processing to x.
}
public static void process1( ){
//do some processing to x.
}
public static void process2( ){
//do some processing to x.
}
....
....
....
}
Then I have class B
public class B extends A {
private static int y;
}
the questions is, when I call B.process(), B.process1(), B.process2(), ....how can i get it process number y instead of number x in its super class?
[671 byte] By [
01010a] at [2007-10-3 9:28:04]

> the questions is, when I call B.process(),> B.process1(), B.process2(), ....how can i get it> process number y instead of number x in its super> class?From Sun's Java Tutorial: http://java.sun.com/docs/books/tutorial/java/IandI/super.html
yes i guess if u name both variables the same say x
and in class A
u used a get function to get x
and then in class B
u override this get function with another function also to get x but in this case u get the x of class B
and then in each time u want to use x u use the get function
the result will be as u desire
but i am not sure that u can inherit a static field or method
no if u each time referenced x with getX function which is overriden in Class B and x is also found in Bwhen u use method B.process it will use x of B
Class A
{
static private int x
static public int getX()
{
return x
}
static process ()
{//instead of x use getX()
}
}
Class B extends A
{
static private x;
static public int getX( )
{
return x;
}
}
B.process will use x of B