1. Output
Package Com.example;public class MyClass { public static void Main (String args[]) { System.out.println ( Byte.min_value + "~" + byte.max_value); System.out.println (Integer.parseint (")"); System.out.println (Integer.tobinarystring ()); System.out.println (Integer.tohexstring ()); System.out.println (integer.tostring);} }
2. Enter
Package Com.example;import Java.util.scanner;public class MyClass {public static void Main (string[] args) { // Scanner input data from the console Scanner Scanner = new Scanner (system.in); System.out.println ("Name:"); String name = Scanner.next (); System.out.println ("Gender:"); char sex = Scanner.next (). charAt (0); System.out.println ("Age:"); int age = Scanner.nextint (); System.out.println ("height"); Double height = scanner.nextdouble (); System.out.print ("character"); String type = Scanner.next (); SYSTEM.OUT.PRINTLN ("Hi everyone, I am:" +name+ ", Gender:" +sex+ ", Age:" +age+ ", Height:" +height+ ", Character:" +type "); rain, female, 22, 1.62, haha }}
3. Basic data types and their conversions
Package Com.example;public class MyClass { public static void main (string[] args) { //1. Long longvalue = 3000000000l; 2. Auto-turn: Byte->short->int->long //strong turn: Long->ing->short->byte //3. BYTE B1 = 5; Because an integer is stored internally as int //So byte B3 = B1 + 3 is wrong and can be changed to the following two forms: byte b2 = (byte) (B1 + 3); int B3 = B1 + 3; 1. float c = 4.3f; 2. Auto-turn: float->double //strong turn: Double->float //char Type: characters, Kanji, English letters, by ' wide up //bool type: True and False }}
3. Output, input, basic data type