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){
 int area()
     return (length*breadth);
 class BedRoom extends Room{
     int height;
     BedRoom(int x,int y,int z){
         super (x , y);
     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();

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?
CEHJConnect With a Mentor Commented:
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 and that class must be the one marked public
Sourodip KunduAuthor Commented:
That means the main part class of the program should be public not any other class?
Sourodip KunduAuthor Commented:
Problem solved
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.