1

Error: Main method not found in class volume, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application

import java.util.*;
class volume {

    private int x;

    public float volume(float l) {
    return (l * l * l);
    }

    public float volume(float r, float h) {
    return (3.14f * r * r * h);
    }

    public float volume(float l, float b, float h) {
    return (l * b * h);
    }
}

class main {

    public static void main(String[] args) {
    volume a = new volume();
    System.out.println("volume of cube=" + a.volume(10));
    System.out.println("volume of cylinder=" + a.volume(10, 10));
    System.out.println("volume of cuboid=" + a.volume(10, 10, 10));
    }
}
1
  • Side note: By convention, Java class names should start with a capital letter. You should rename class volume to Volume and class main to Main. Commented Dec 17, 2014 at 9:57

5 Answers 5

1

Move your main method to volume class and make volume class public. You don't need class main.

Sign up to request clarification or add additional context in comments.

Comments

0

remove class main { and } then you will have a main method in Volume class

Comments

0

Your program works fine. you just compile the main class and execute the main class.

Comments

0

Logically, the main method should be inside the class Volume. In spite of that, your code should have worked. But the real reason you are getting the error is because remember: in Java, the class names have to start with an uppercase.

Simply rename the class volume as Volume, and main as Main and it should work.

Comments

0

Please change your public class in your program. Then everything works fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.