As discussed in Packages Packages are used to group related classes. Now we will see how to compile classes in packages.
Now i have a two program BedRoomLight.java and HallLight.java at the locations E:\src\house\bedroom and E:\src\house\bedroom
INSERT SHOWING PACKAGES IMAGE HERE INSERT SHOWING BEDROOMLIGHT PROGRAM INSERT SHOWING HALLLIGHT PROGRAM Here I considered BedRoomLight as super class and HallLight is extending it. /* BedRoomLight.java */ /* HallLight.java */ HallLight program at LINE A we are creating an object for BedRoomLight and calling the print method in BedRoomLight . At LINE B we are creating an object for HallLight and calling HallLight print method.Now we want to compile these program and execute them we should do as follows in the command prompt. INSERT IMAGE OF COMPILING BEDROOMLIGHT INSERT IMAGE OF COMPILING HALLLIGHT E:\src>javac house/bedroom/BedroomLight.java I am Bedroom light I am Hall light Note : To compile the programs we should be in the parent directory. So here i started from src
|