I'm a fledgling programmer for the first year. This is a collection of personal notes that have been organized and published for review purposes. Please note that there is a high possibility that you are wrong.
int number; //Declare variable number of type int
String str; //Declare a variable str of type String
int[] list; //Declaration of array list of int type
ArrayList<String> arrList; // ArrayList<String>Declare the variable arrList of the class
--Declare in the order of type variables
int number = 27; //Variable initialization (assigning a value for the first time)
String str = "hello"; //String type initialization, string""Enclose with (double quotation marks)
int[] list = new int[3] //Creating an array
List<String> arrList = new ArrayList<String>(); //Instantiation of ArrayList class
--If not initialized, the initial value is set to 0 for numeric types such as int and double, false for boolean type, and null for reference type. --Learn later what the instance is
final int NUMBER = 5;
--If final is added, it becomes a constant and an error occurs when trying to assign a value. --By convention, constants are often capitalized.
Primitive type | Contents | size | range |
---|---|---|---|
long | Large number | 64bit | -9223372036854775808 ~ 9223372036854775807 |
int | Normal number | 32bit | -2147483648 ~ 2147483647 |
shot | Small number | 16bit | -32768 ~ 32767 |
byte | Very small number | 8bit | -128 ~ 127 |
double | Decimal | 64bit | about(-)3.40282347E+38(about6~7桁の精度) |
float | Decimal numbers with relatively low precision | 32bit | (-)1.79769313486231570E+388 (15-digit precision) |
boolean | True or false | 16bit | true or false |
char | 1 Unicode character | 1bit | \u0000 ~ \uFFFF |
--Typical example is String class, reference type if not primitive type
reference) About Java Primitive Types and Reference Types
System.out.print((int)3.2); //The result is 3
--Forcibly perform type conversion by explicitly performing type conversion --It seems that it is not used much because data is lost.
--String → Numerical value
Integer.parseInt(str)
Integer.valueOf(str)
Such
--Numeric value → character string
number.toString()
String.valueOf(number)
Such
I wrote a lot, but I thought it would be better to see Java Road. So let's look at this (round throw).