2.1 Variables and Data types:

2.1.1 Data Type:

Data types: Java is a strongly typed language, with explicit data types defined for each type of data

Data type: Basic data type + reference data type

2.1.1.1 Basic Data types

One with eight basic data types:

The name of the Java The number of bytes
Byte type byte 1
Short integer short 2
plastic int 4
Long integer long 8
Single precision float 4
double double 8
The Boolean boolean 1
character char 2
package day_05_25;
/* * There are several types of data in Java: * two basic data types and reference data types * How many basic data types are there: * 8: * byte short int long float double Boolean char * * A: scope: * A variable is valid within the braces {} in which it is defined, and the same variable name cannot be defined within the same braces. * a: datatype variable name = initial value; a: datatype variable name = initial value; * b: data type variable name; * Variable name = initial value * * */
public class demo02 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		int k=23,j;
		j=24;
		System.out.println(j);
		
		byte b = 23;// bytes (low frequency)
		short s =21313;// Short integers have the maximum number of five digits
		int i = 231231321;/ / integer
		long l = 231313131313131313l;// Long integer, followed by L
		 double d = 2.131;// Double precision, decimal point
		 float f = 2.313 F; // Single precision, then add F
		 boolean bf = false;
		 boolean bt = true;
		 
		 // Do not use:
		 char c= 'A';
		 char c1 = 'in';
		 char c2 = ', '; }}Copy the code
2.1.1.2 Reference Types

One kind consists of five kinds:

The name of the Java
class class
interface interface
The enumeration Enum
An array of DataType[]
annotations Annotation

The reference type corresponding to the base data type

Basic types of Reference types
byte Byte
short Short
int Integer
long Long
float Float
double Double
boolean Boolean
char Character