Java Basic syntax
A Java program can be thought of as a collection of a series of objects that call each other's methods to work together.
Introduction to classes, objects, methods, instance variables:
Class: A class is a template that describes the behavior and state of a class of objects
Object: Object is an instance of a class that has state and behavior (properties and methods)
Method: The method is the behavior of the class and can have multiple
Instance variables: Each object has its own unique instance variable, and the State (property) of the object is determined by the value of the instance variable
Basic syntax
1, case sensitive, for example: The identifier Hello and Hello is not the same
2. The first letter of the class name should be capitalized, for example: Myfirstjavaclass
3, the method name initials should be lowercase, there are multiple words, then each word should be capitalized, for example: Myfirstmethod
4, save the file, the source file name must match the class name, or the compilation will be error
5. Main method entry, all Java programs are executed by public static void main (String []args) method
Java identifiers
1. All identifiers should start with a letter (A-Z or a-Z), a dollar symbol ($), or an underscore (_).
2. The first character can be a letter (A-Z or a-Z), a dollar symbol ($), an underscore (_), or any character combination of a number
3. The keyword cannot be used as an identifier and is case sensitive
Examples of legal identifiers: Age, $salary, _value, __1_value
Examples of illegal identifiers: 123abc,-salary
Java modifier
1. Access control modifier: default, public, protected, private
2. Non-access control modifier: final, abstract, STRICTFP
Java Basic syntax