0

Extends

How can i use the (extends ) on this programm ? I can‘t open two classes in the same time. Thank you all

23rd Jan 2022, 1:10 PM
Mohammad
3 Respuestas
+ 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(); } }
23rd Jan 2022, 2:05 PM
Coding Cat
Coding Cat - avatar
+ 1
Thank you very match
23rd Jan 2022, 4:35 PM
Mohammad
+ 1
also two classes can be public in one file here (it is not standard java feature)
23rd Jan 2022, 6:29 PM
zemiak