Question by hayatte: java!!!!please help me?
well i wrote this i did the compilation but it gave me this msg when running Exception in thread “main” java.lang .NoSuchMethodError:main

the thing i wrote was the following
public class MainClass

{

}

class Demo1
{
public static void main (String [] args)
{
System.out.println(“welcome to java programming”);

}
}
please could u explain it in a simple way !!!!!and why this happened
please could u explain it in a simple way !!!!!and why this happened

Best answer:

Answer by M. L.
You have two classes here. MainClass, which has nothing in it, and Demo1, which has your main(). If you ran your program pointing to MainClass, then you’ll get what you see there.

Either:
1) Move your main() method into MainClass

2) Execute your program using Demo1 as the main class.

NOTE: If these two classes are in the same file, I would HIGHLY recommend separating them out.

What do you think? Answer below!

One thought on “java!!!!please help me?”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.