+ 3

In Java can we use import keyword instead of Inheritance for doing the same work?

In java we use extends keyword as Inheritance. But can we use import keyword for the same work? It'll make my program easier.

29th Jun 2018, 4:48 PM
Swarnadeep Ghosh
Swarnadeep Ghosh - avatar
2 Antworten
+ 4
Swarnadeep Ghosh No bro. try to understand.... 1-->java used package because they want to access the class file which was kept in other loaction to acces that file in other location for eq D:\folder\packagr\Test.class E:\folder\package\Test1.class 2-->by default our java program run on a default package... i.e the only reason implicit compilation can be done by java... 3.. and we know that all. class file of java store in rt.jar so java already provide the path.. so we just import that. class file from that locations to our location.. i.e we need import statement.. these work cant be done bu inheritance,untill and unless we dont give the address hardcode for eq class A extends java.awt.Frame { } so what we do here we give the whole address here
29th Jun 2018, 6:01 PM
Arun Tomar
Arun Tomar - avatar
0
thanks bro
1st Jul 2018, 9:17 AM
Swarnadeep Ghosh
Swarnadeep Ghosh - avatar