__ Write my own Java reference! Hey __ Make a note aiming to acquire Java Brongo, I think you may make a mistake, so point it out.
System.out.println("Hello World");
System.out.print("Hello World");
Output with print, output with print ln, and then start a new line. ln means line. In other words, println means print-> line (line feed).
int i = 0;
Type variable name = value;
Everyone knows the one I always use
Add public, private, protected, or static to the type name.
What is static (I will write it someday)
int[] hoge = new int[3];
int hoge[];
Type [] Variable name = new Type [length];
You can also declare the type of a variable by writing the type variable name [];
(note that it is not initialization), but it is not common as a remnant of C language.
If you actually write in IntelliJ IDEA, you will be warned that you should use Java style.
int[] hoge = new int[] {0, 1, 2, 3, 4};
int[] hoge = {0,1,2,3,4}; //↑ abbreviation
Type [] Variable name = new Type [] {Value 1, Value 2, Value 3, Value 4, Value 5 ...};
By the way, the new type []
can be omitted as follows. Generally, this is more commonly used.
Type [] Variable name = {value 1, value 2, value 3, value 4, value 5 ...};
int n = hoge.length;
You can get the length of the array with the array name .length. Return value is int type
Note that it is not the number of elements. When initialized with type [] variable name = new type [3];
, variable name.length
returns 3
.
Recommended Posts