Let’s take a look at what’s familiar and see what the simplest Java program looks like!
/**The first Java program*/publicclassMain{publicstaticvoidmain(String[]args){System.out.println(Hiwww.dotcpp.com);}}
You can run this code on the dotcpp online compiler, and you can see that the string "Hi www.dotcpp.com" will be output. This is the effect of this small piece of code. Here is a detailed introduction to you:
First of all, we see that the statement that outputs this string is a System.out.println statement. In fact, we can modify the content in the double quotes in this statement. Whatever we modify will be output. In other words, this is an output statement . We just need to You can output the information you want to output by putting it in double quotes after this statement. You can try it.
Secondly, we see that the println statement is enclosed in parentheses of a public static void main. This is a method called main . It is the entry point of the program, which means that all the code starts executing from here. pirntln is this The only statement in the method, and the public static in front of the main method indicates that the main method is a publicly accessible static method.
Then look at the outer layer. The function public static void main is inside the parentheses of public class Main. Public class Main is a class. Similarly, public means that the access rights of this class are public. Class is a keyword. Class , followed by Main is the class name .
You can try to understand this small piece of code, and there is no need to feel pressure to understand it, because it will be used extensively and in-depth understanding will gradually deepen later.