Post by account_disabled on Dec 12, 2023 5:46:05 GMT
Class names are usually written in the , each with a capital letter. It is desirable to give classes, as well as other entities methods, fields and variables mnemonic and meaningful names. The body of the class is written after the name in curly braces. It can contain fields, methods, and other classes. Fields store data. They are similar to variables, but in Java they are a slightly different entity. Methods contain a set of commands or code. Method names as well as field and variable names are usually written in camel.
Case style with lowercase letters. Our class has only one method main. He is special, he is often called the owner. When the Java Virtual Machine receives a class to run, it looks Phone Number List for its main method. If it finds one, it executes the code containing the method. Otherwise, an error message is issued. It is important that the main method has a strictly defined signature it is public, static, does not return any value void , with a parameter in the form of an array of strings String args.
Otherwise, the virtual machine simply will not find it. Our main method contains only one line, which outputs the text Hello, world! On the console! Before compiling, save the written code to a file. The file name must match the class name up to uppercase Java is a case sensitive language. So, we open a command prompt or terminal and first call the compiler javac and then the JVM virtual machine java. C Users User> javac HelloWorld java C Users User> java HelloWorld Hello world! After compilation, a HelloWorld class binary file will appear containing the bytecode.