Error in Eclipse - Mainclass not found

≯℡__Kan透↙ 提交于 2019-12-02 06:38:01

when you run java it runs main method that i don't see in your class so basically eclipse is telling you: "what do you want me to run?", you should implement it:

public static void main(String[] args){
    // code here
}

I found another error.

  public int  (int carry) // Setting carry into the elevator
{
    currentCarr = carry;
    if (currentCarr != 0) {
        fillCondition = true;
        return 1;
    } else {
        return 0;
    }
}

Method can't be called 'int'. This name is reserved by the Java language.

When developing a core-java application, all you need to do is to have a main method (ofcourse with the functionality :P) in it which is the first code fragment JVM Searches for when you try to run your application. For the above code, try this:

public static void main (String [] args) {

//Now, make an instance of your class to instantiate it.

Elevator obj = new Elevator();

//Then,as per the desired functionality. Call the methods in your class using the reference.

//obj.move(val of stage);

obj.move(10);
}

Just make sure to have a main method for executing your java code. Happy Coding :)

the access point for java is the main method.. every program must access from a main method. and in main method, you need to create an instance of your class to use the method inside main method like following:

public static void main(String [] args){
  Elevator elevator = new Elevator();
  elevator.move(1);
  ...
}

and also public int (int carry) // Setting carry into the elevator is not valid format in Java, you have to define a method name like

public int setCarry(int carry) // Setting carry{
  //your code
}
Abdullah Al Asif

We can't run a Java program without

public static void main(String[] args) {
}

The program only executs the main method. In the main method you can create objects like

Elevator elevator = new Elevator();

You can put the main method anywhere.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!