Types of data Java common data types
1.int
2.Double
3.Char
4.String
Variable declaration and use
Use declared variables or data stored in a variable's memory space, but remember that "variables must be declared and depreciated before they can be used." Therefore, to use a variable, the declaration and depreciation of the variable is essential.
Variable naming rules
1. The variable must begin with a letter, an underscore "" or a "$" symbol
2. Variables can include numbers, but cannot start with a number
3. Variable names cannot contain any special symbols other than "-" or "$" symbols
4. Cannot use Java language keywords, such as int,class,public, etc.
Depreciation operator
1. "=" You can assign a value to a variable, or assign the value of an expression to a variable. An expression is a combination of a symbol (such as a plus sign, minus sign) and an operand (such as a b,3, etc.)
Arithmetic operators
1. +
2.-
3./
4.%
Data type conversions
The form of data type conversion is divided into automatic data type conversion and forced data type conversion.
Boolean type
The Boolean type has two values, and only these two values.
1. Teun
2. False
Relational operators
1. >
2. <
3. >=
4. <=
5. = =
6.! =
Pulic class java{
public static void Main (string[] args) {
Scanner input=new Scanner (system.in);
System.out.println ("Please enter the principal")
Double Money=input. Nextdouble ();
System.out.println ("Deposit one year's principal and interest" +money*1+ (0.0225));
System.out.println ("Deposit two years ' principal and interest" +money*1+ (0.027*2));
System.out.println ("Deposit three years ' principal and interest" +money* (1+0,0324*3));
System.out.peintln ("Deposit five years after the principal and interest is" +money* (1+0.036*5));
}
}
Chapter II variables, data types and operator insights