0
Extends
How can i use the (extends ) on this programm ? I canāt open two classes in the same time. Thank you all
3 Answers
+ 2
You can do it the normal way.
Like this example :
(And read Java lesson 43.1)
class Animal {
protected int legs;
public void eat() {
System.out.println("Animal eats");
}
}
class Dog extends Animal {
Dog() {
legs = 4;
}
}
class MyClass {
public static void main(String[ ] args) {
Dog d = new Dog();
d.eat();
}
}
+ 1
Thank you very match
+ 1
also two classes can be public in one file here
(it is not standard java feature)