Zilong
Function: Display "Hello" in console
Date: 2017-04-11
Public: Indicates that the class is a common class, and that there can be only one publicly class in a Java file
Class: Indicates that this is a category
Hello: Class name (the class name of the public class must be the same as the file name)
public class Hello
{
A main function, equivalent to the entry of a program
public static void Main (String args[])//main function, only one main function in a common class
{
EXECUTE statement
System.out.println ("hello!");
/* int a=10; Define a variable, the variable name a, and its value 10
int b=20; Define a variable, variable name B, whose value is 20
int result=a+b;
Output results
SYSTEM.OUT.PRINTLN ("The result is" +result); */
Char char1= ' q ';
System.out.println (CHAR1);
int test1= ' A ' + ' B ';
System.out.println (test1);
Char test2= ' a ' + ' B ';
System.out.println (TEST2);
This violates the principle that data is converted from high-precision to low-precision.
Byte<short<int<long<float<double
In Java 3.4, 4.5 decimal is the default double data type
int a=1.2;
float a=3.4f;
System.out.println (a);
int a= (int) 1.2;
int b= (int) 1.9;
System.out.println ("a=" +a+ "b=" +b);
int a=1;
Double b=4.5;
A=b;
B=a;
int a=3;
int b=a+3.4;
System.out.println (b);
}
}
————————————————————————————————————————
The Java language provides eight basic types. Six types of numbers (four integers, two floating-point types), one character type, and one Boolean type.
1, integers: including int,short,byte,long
2. Float Type: float,double
3, Character: Char
4, Boolean: Boolean
| Basic type |
Size |
Minimum value |
Maximum Value |
| Boolean |
----- |
----- |
------ |
| Char |
16-bit |
Unicode 0 |
Unicode 2^16-1 |
| Byte |
8-bit |
-128 |
+127 |
| Short |
16-bit |
-2^15 |
+2^15-1 |
| Int |
32-bit |
-2^31 |
+2^31-1 |
| Long |
64-bit |
-2^63 |
+2^63-1 |
| Float |
32-bit |
IEEE754 |
IEEE754 |
| Double |
64-bit |
IEEE754 |
IEEE754 |
| void |
|
|
|
"Java" Cubs first: Java basics