+ 1

How will I inherit the methods of a class

suppose I have class x in y package and in y I have another package named z and a class in it as a.. all are public.. if I want to inherit the methods of a in x how can I do that.. my ide is bluej

28th Jun 2018, 3:46 PM
Abhi
Abhi - avatar
8 odpowiedzi
+ 5
Abhi fist you have to import the paclagae. then you have to set the classpath. import y.*; import y.z.*; class x extends y.z.a { } like this Note Multiple inheritance is not allowed in java in case of classes
29th Jun 2018, 3:49 AM
Arun Tomar
Arun Tomar - avatar
+ 4
Abhi extends with package name"." class name
28th Jun 2018, 3:56 PM
Arun Tomar
Arun Tomar - avatar
+ 2
Abhi if you want to run a main class package. so remember package is not executable in java. so if you want to run that class so you have to do this java package_name.class file name at cmd
29th Jun 2018, 2:18 PM
Arun Tomar
Arun Tomar - avatar
+ 2
Abhi yes you can do that
29th Jun 2018, 2:20 PM
Arun Tomar
Arun Tomar - avatar
+ 1
i have to inherit multiple classes from that package then
29th Jun 2018, 12:30 AM
Abhi
Abhi - avatar
+ 1
here comes a problem. . I want to import classes in one main class and run each class as per user's choice. . so what should I do
29th Jun 2018, 1:59 PM
Abhi
Abhi - avatar
+ 1
I got that.. can I move my all classes into packages and later on import them at once
29th Jun 2018, 2:19 PM
Abhi
Abhi - avatar
+ 1
then I got my solution
29th Jun 2018, 2:20 PM
Abhi
Abhi - avatar