Java basic grammar rules, identifier naming rules, keywords

1. Basic grammar

  • Case Sensitivity : JAVA is very case sensitive, so A and a are different when you define variables. (Current programming languages ​​are case-sensitive except for VB and SQL statements that are case-insensitive.)
  • Class names : For all classes, the first letter of the class name should be capitalized. If the class name consists of several words, the first letter of each word should be capitalized, such as MyFirstJavaClass. (And this nomenclature is also known as "CamelCase")
  • Method names : All method names should start with a lowercase letter. If the method name contains several words, capitalize the first letter of each subsequent word.
  • Source file name : The source file name must be the same as the class name. When saving the file, you should use the class name as the filename (remember that Java is case-sensitive), and the filename suffix is ​​.java. (If the filename and classname are not the same it will cause a compile error).
  • Main method entry : All Java programs are executed by the public static void main(String []args) method.

2. Identifier naming rules

  • All identifiers should start with a letter (AZ or az), dollar sign ($), or underscore (_)
  • The first character can be followed by any combination of letters (AZ or az), dollar signs ($), underscores (_) or numbers
  • Keywords cannot be used as identifiers
  • Identifiers are case sensitive

3. Keywords

  • In the java language, some special words have been given special meanings, and these words can no longer be used to name identifiers. These special words are called "keywords".
  • Java has 50 keywords and 3 reserved words, none of which can be used to name identifiers
  • true, false, and null are not keywords, but reserved words, but they cannot be used to name identifiers. Reserved words are keywords reserved by Java, and may be used as keywords in future upgrades;

insert image description here
[1]:http://www.runoob.com/java/java-basic-syntax.html
[2]:https://www.cnblogs.com/fendoudeya/p/j2se_java01.html

Guess you like

Origin blog.csdn.net/MCYZSF/article/details/88897032