My Java reference

__ 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.

Basic

Hello World

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).

Variable declaration

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)

Array

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. image.png

Initialize the array as soon as it is declared

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 ...};

Get the length of the array

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

My Java reference
My DOM (Java)
Java8 method reference
My StAX (Java)
java8 method reference
My DAO pattern (Java)
My Android learning reference
My Study Note (Java)
[Java] Integer wrapper class reference
Java VB.net service reference halfway
A reference book that my brother had, had, had Ruby, Java
Java
Java
Basic data types and reference types (Java)
Java primitive types, reference types, Immutable, Mutable
Java reference mechanism (stack and heap)
Java array variables are reference types
Java pass by value and pass by reference
[Java] Reference / update of Active Directory
About Java primitive types and reference types
Java "pass by reference" problem summary
About returning a reference in a Java Getter
Java learning (0)
My thoughts on the equals method (Java)
Studying Java ―― 3
[Java] array
Java protected
[Java] Annotation
[Java] Module
Java array
Studying Java ―― 9
Java scratch scratch
Java tips, tips
Java methods
Java method
java (constructor)
Java array
java (override)
[Easy-to-understand explanation! ] Reference type type conversion in Java
java (method)
Java Day 2018
Java string
Java reference to understand in the figure
Java static
Java serialization
java beginner 4
JAVA paid
Studying Java ―― 4
Java (set)
[Java] compareTo
Studying Java -5
java reflexes
java (interface)
Java memorandum
☾ Java / Collection
Java array
[Java] Array
Studying Java # 0
Java review
java framework
Java features