Home > Back-end >  Bosses, Java for help
Bosses, Java for help

Time:09-25

This is why it's always let delete operation not static but deleted code

CodePudding user response:

Public class Parent {
Int x=100;
Void m () {
System. The out. Println (x);
}
}
The class Child extends the Parent {
Int x=200;

Public static void main (String [] args) {
The Child a=new Child ();
Arjun ();
System. The out. Println (a.x);
}
}

//the Child in the Parent, you write is wrong, the inner class has no such usage

CodePudding user response:

reference 1st floor songleong response:
public class Parent {
Int x=100;
Void m () {
System. The out. Println (x);
}
}
The class Child extends the Parent {
Int x=200;

Public static void main (String [] args) {
The Child a=new Child ();
Arjun ();
System. The out. Println (a.x);
}
}

//the Child in the Parent, you write is wrong, the inner class has no such usage
he says can not find the main method in the Parent class

CodePudding user response:

You this writing I didn't understand, or you can take out your child whole class write the parent in the above change the file name to the child for the parent to do an inner class, because you are now the main method belongs to the child, so there will be the main method in the parent zha