Java Summary
- Common code: Scanner in = new Scanner (system.in);
- Usage of shortcut keys
- Note: Crtl +/
- Fast input: Alt +/Mac:option +/
- Select line of code: SHIFT + up/down arrows
First, floating point number
Second, priority
Iii. type Conversion
1.1 Floating-point numbers-this does not fully display, the floating-point number conflicts with Int.
Solution:
-
- 12 instead of 12.0
- Modify inch
- int inch change to double inch
- Nextint instead of an int instead of a double nextdouble read in.
ImportJava.util.Scanner; Public classHello { Public Static voidMain (string[] args) {//TODO auto-generated Method Stub//5 feet, 7 inches tall? Conversion//formula (5+7)/12*0.3048 intFoot; intinch; Scanner in=NewScanner (system.in); Foot=In.nextint (); Inch=in.nextint ();//System.out.println (10/3);//The result can only be integers, 10 and 10.0 are different in Java 10.0 is a floating-point numberSystem.out.println ("foot=" + Foot + ", inch=" +inch);//View Output ResultsSystem.out.println ((FOOT+INCH/12) *0.3048); }}
1.2. How floating-point numbers are stored in the computer
2.1 Priority level
1. General operators: Thinking of normal thinking
2. Special operators:
- Monocular operator
- Binding Relationship-Assignment Operation result=a=b = 3+c (still thinking with conventional thinking)
3.1 Type conversions
Final display Results
Other examples
- int i = 32/3.0;
- int i = (int) (32/3.0); Values and types are bracketed, not changing the original value
Introduction to Java Programming _ first week (bottom)