class InfoWeather {
static int month;
static int day;
static String sky;
}
class DateInfo {
public static void main (String args []) {
InfoWeather.month = 8;
InfoWeather.day = 10;
InfoWeather.sky = "rain";
System.out.println (InfoWeather.month + "month" + InfoWeather.day + "day" + InfoWeather.sky);
}
}
I put it like this and ran it, but I can not find the main (String []) method in the class in the terminal: InfoWeather It is written and I do not know where to fix so please reply!
-
Answer # 1
-
Answer # 2
As the error message says,
InfoWeather
In classmain
There is no method.File name
DateInfo.java
Change toDateInfo
ofmain
Let's make it read when loading.(Note that you should only write one class per file in Java, except for very simple examples and nesting classes)
Related articles
- java - the main (string []) method not found in the class: educlass came out
- java - method using graphics class created in another file cannot be used in main method of main class
- java - error: want to resolve main (string []) method not found in class
- java scanner class nextline () method operation
- java - i don't understand the method call inside the class type method
- java - to create a method and call it from another class
- ruby - i want to know the reason for implementing it in a class method or module when solving an exercise
- java - class field initialization
- java - rotate character string to the right, rotate left: the expression to rotate the given string abc by 1 for rotation to the
- [java] code that shuffles a character string does not work if it has more than 11 characters
- [java] i want to insert a specified character string in the input part on the console
- java - about flatmap method
- java - how to pass values by class
- method of confirming equivalence of different types in java
- java instance generation method
- java - about types such as string int
- java - i want to use the return value of one method in another
- java - i don't know the cause of the error "this method must return a result of type ○○○○"
- java - about the stringvalueof () method
- java - how to use the inner class setter getter
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
Did you see the error and run it without compiling the source file?
>java DateInfo.javaIf you run it without compiling, it will try to call the main () method for the first written class.
Therefore, even if you try to call the DateInfo class, the InfoWeather class that does not have a main () method is called, and the error that the main () method cannot be found is displayed.
It's recommended to compile and run it, but if you want to run it directly, move the class you want to run to the top of the file.