A Java program can be thought of as a collection of a series of objects that can work together by invoking each other's methods.
Object: Is an instance of a class that has state and behavior. For example, a dog is an object whose state is: color, name, variety, behavior: wagging the tail, barking, eating, etc.
Class: A class is a template that describes the state and behavior of a class of objects.
Method: Is the behavior, a class can have many methods. Logical operations, data modifications, and all actions are done in a method.
Instance variables: Each object has a unique instance variable, and the state of the object is determined by the value of these instance variables.
A simple Java program that prints a string.
1 Public classHelloWorld {2 //It will print the string Hello world3 4 Public Static voidMain (String []args)5 {6System.out.println ("Hello World"); 7 //Print Hello World8 }9}
Note objects when editing a Java program:
1. Case: Java is case-sensitive, which means that the identifier Hello and hello are not the same.
2. Class name: For all classes, the first letter of the class name should be capitalized. If the class name consists of multiple words, the first letter of each word should be capitalized, such as MyName.
3. All method names should start with a lowercase letter. If the method contains more than one word, it should be capitalized in the first letter.
4. Original file name: The source file name should be the same as the type name. When saving the file, you should use the class name to save the filename (remember that Java is case-sensitive), and the suffix of the file name is. java.
5. Main Method Portal: All Java programs are executed by the public static void main (String [] args) method.
Java variables:
Local variables
class variables (static variables)
Member variables (non-static variables)
Java Basic syntax