Introduction to Java Basics (Zhizhi) Summer Preparatory Notes (1) 7.18

  • The basic syntax of Java
    [modifier] class class name { program code }

public class Helloword{
    
    
         public static void main(String[ ] args) {
    
    
             System.out.printIn(”你好呀");
          }
      }

Pay attention to capitalization and typesetting issues
{The first line of code in the left brace must be indented
ctrl+ shift+ F keys to quickly format the code.
A continuous string cannot be separated. Write in two lines, that is, the content in the same double quotation mark cannot be separated Write in two lines.

  • Comments in Java
    1. Single-line comments: In English state //
    2. /*
    Multi-line comments
    (can wrap)
    /
    3./
    *
    Document comments
    */
    Notes for comments
    1. Nesting problem
    A: Single-line comments can be nested
    //This is a single-line comment.//This is also a single-line comment.
    Document comments cannot be nested.
    Multi-line comments cannot be nested.

  • Keywords in Java
    Keywords refers to words that have been given some special meanings in programming languages.
    Features: 1. All lower case
    2. For some advanced programming tools, there will be color highlighting.
    The keyword used to import the package is: import

  • Identifiers in java
    1. Components
    English uppercase and lowercase letters
    Numbers 0-9, underscore_ dollar sign $
    2. Notes on naming
    numbers cannot start
    with keywords in Java. It is
    best to see the name and the meaning
    3. Recommended naming method
    (1) Name the package: The general recommendation is to reverse the company domain name www.itheima.com
    com. itheima. Project name. Module name and use between packages. Split the package name in all lowercase
    (2) Give the class , Interface naming: If it is a word: Capitalize the first letter is recommended; If it is multiple words: Capitalize the first letter of each word
    For example: ArrayList Student
    (3) Name the constant: require each letter in the word to be capitalized; if It is a number of words, use the downward writing segmentation.
    For example: MAX_VALUE
    (4) Name the variables and methods: if it is a word: all letters are recommended to be lowercase; if it is multiple words: it is recommended to start with the second word and each first letter is capitalized.
    For example: name getName

  • Definition
    of Variables What is a variable?
    In the running process of a program, its value is the amount that can be changed, which is called a variable.
    Definition format: data type variable name = variable value;

public class Deom04{
    
    
       public static void main(String[  ] args) {
    
    
              //定义一个变量
              int number=5;
              int sum;
              sum=number+5;
              System.out.printIn(number);
              System.out.printIn(sum);
        }
}

Guess you like

Origin blog.csdn.net/wssgakki/article/details/107437306