After using main method in the code though it showing main error that " Main method not found "

HI, I am a newbie in Java and I have done the following programme using extend keyword. The code is  as follows.



package room;


public class Room {
 int length;
 int breadth;
 
  Room(int x, int y){
     length=x;
     breadth=y;
 }
 int area()
 {
     return (length*breadth);
 }
}
 class BedRoom extends Room{
     int height;
     
     BedRoom(int x,int y,int z){
         super (x , y);
         
                 height=z;
     }
     
     int volume()
     {
         return (length*breadth*height);
     }
 }
 
 class InherTest{
     
       public static void main (String[] args)  {
         
         BedRoom room1 = new BedRoom(14,12,10);
                 int area1=room1.area();
                 int volume1=room1.volume();
                 System.out.println("Area1="+area1);
                 System.out.println("Volume="+volume1);
     }
 }

Open in new window


Now when I run this programme it shows the following error


Error: Main method not found in class room.Room, please define the main method as:
   public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
C:\Users\h\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)


What is the problem and how to fix it?
Sourodip KunduAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Don't try to cram all classes into the same compilation unit. You're allowed only one public class per compilation unit. So, if you want to 'run that file' it must be called InherTest.java and that class must be the one marked public
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sourodip KunduAuthor Commented:
That means the main part class of the program should be public not any other class?
0
CEHJCommented:
Yes
0
Sourodip KunduAuthor Commented:
Problem solved
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.