Search code examples
javaprogram-entry-point

Can we add the main method in class after creating the class without main method in eclipse?


Can we add the main method in class after creating the class without main method in eclipse?

I created a class and am trying to add main method after creation, it is not picking up.

Error: Editor does not contain a main type,


Solution

  • @kalyan-chavali, Could you please share code so that we get more details. As it's working for me ..

    public class HelloWorld {
        private static void sayHi() {
            System.out.println("Say Hi");
        }
    
        public static void main(String[] args) {
            System.out.println("Say Hello World");
            sayHi();
        }
    }