Organized memo in the head (Java --Data type)

My Java environment

Java data type

Primitive type (use the value itself, null cannot be assigned.)

Reference type (handles a reference to an instance)

n-ary

Numerical notation using underscore


int value = 123_456;
System.out.println(value);

The display result is

123456

Identifier naming convention

Type inference (var)

Type inference is done at compile time.

OK

var value = 123;
var value = method();
var value = new ArrayList<>();

NG


var value;
var value = null;
var value = {1, 2, 3};
var value =Lambda expression

var classA = new ClassA();
classA = new ClassB();

mutable and immutable

mutable

immutable

Type range

byte < short < int < long < float < double

Baishoiro Fuda

Type conversion

Explicitly cast from large to small.


int value1 = 123;
short value2 = (int)value1;

Identity and equivalence

Recommended Posts

Organized memo in the head (Java --Data type)
Organized memo in the head (Java --Array)
Organized memo in the head (Java --Control syntax)
Organized memo in the head (Java --instance edition)
Java learning memo (data type)
Organized notes in the head (Java-Exceptions)
[Personal memo] Java data type is annoying
The intersection type introduced in Java 10 is amazing (?)
[Java] Data type ①-Basic type
Try functional type in Java! ①
Importing Excel data in Java 2
Import Excel data in Java
Importing Excel data in Java 3
Guess the character code in Java
Display Firestore data in RecyclerView [Java]
Specify the java location in eclipse.ini
[Java] Data type / matrix product (AOJ ⑧ Matrix product)
Unzip the zip file in Java
Call the super method in Java
[Android / Java] Understand the description type in listener settings (button installation)
Get the result of POST in Java
Java date data type conversion (Date, Calendar, String)
Declare a method that has a Java return value with the return value data type
Regarding String type equivalence comparison in Java
Create variable length binary data in Java
[Easy-to-understand explanation! ] Reference type type conversion in Java
Java reference to understand in the figure
Call the Windows Notification API in Java
[Java] Data type / string class cheat sheet
I tried the new era in Java
[Java] Introducing the Generics Boundary Wildcard Type
Memo: [Java] If a file is in the monitored directory, process it.
[Java] Use cryptography in the standard library
Java memo
Reason to add L to the number to be put in Java long type
How to get the date in java
The story of writing Java in Emacs
Console input in Java (understanding the mechanism)
Display message dialog in java (personal memo)
I received the data of the journey (diary application) in Java and visualized it # 001
Regarding the transient modifier and serialization in Java
The story of low-level string comparison in Java
[Java] Handling of JavaBeans in the method chain
About the idea of anonymous classes in Java
ChatWork4j for using the ChatWork API in Java
A story about the JDK in the Java 11 era
The story of learning Java in the first programming
Measure the size of a folder in Java
About var used in Java (Local Variable Type)
Feel the passage of time even in Java
[Processing x Java] Data type and object-oriented programming
Memo: [Java] Get Raspberry Pi data by SFTP
[Java] Read the file in src / main / resources
Display "Hello World" in the browser using Java
[Java] Judgment by entering characters in the terminal
Display "Hello World" in the browser using Java
Try using the COTOHA API parsing in Java
[Java] Memo on how to write the source
[Java] Something is displayed as "-0.0" in the output
Import files of the same hierarchy in Java
Java type conversion