Java study memorandum

I started studying Java, so a memorandum

Unlike Ruby, when using variables, you have to declare the type I had a lot of things to remember about modifiers, so let's look back on ourselves. I came up with the idea. Also, to learn Markdown notation ...

Type of type

It is divided into ** primitive type ** and ** reference type **. Among them, primitive types are classified into integer types, floating point types, and so on. Reference types are divided into wrapper classes and string classes.

Primitive type

Model name Type classification size(bit) initial value value
long integer 64 0L -9223372036854775808 ~ 9223372036854775807
int integer 32 0 -2147483648 ~ 2147483647
short integer 16 0 -32768 ~ 32767
byte integer 8 0 -128 ~ 127
double Floating point 64 0.0d Double precision floating point number
float Floating point 32 0.0f Single precision floating point number
boolean logic 1 false true / false
char letter 16 \u0000 Unicode single character(¥u0000~¥uFFFF)

When declaring variables, be careful to use the appropriate type so as not to waste memory.

** Integer type ** Normally, the [int] type is used. Use [long] type for large values Integer values are treated as [int] type in the program. When dealing with integers that come out of the [int] type range, write [L] or [l (lowercase L)] at the end of the number. Must be shown to be of type [long].

** Floating point type ** Normally, use the [double] type. When dealing with the [float] type, it is necessary to write [F] or [f] at the end of the value.

** Logical type ** Only boolean values [true] and [false] can be stored.

** Character type ** Only one character can be stored in one variable. When writing common characters, it is necessary to enclose them in ['(single quotation marks)]. No character code is required.

Reference type

A type that holds the reference destination where the data is stored instead of handling the data

If, the baldness is not stored in the string, but the reference destination with the data baldness is held.

** String class (String type) ** A class that handles strings. When writing in a program, enclose it in ["(double quotation marks)]. It is treated as [String] type in the program.

** Wrapper class ** A class that allows primitive types to be treated as wrapper classes. It will be possible to handle things that cannot be handled by primitive types (will be described later).

Primitive type Wrapper class
long Long
int Integer
short Short
byte Byte
double Double
float Float
boolean Boolean
char Character

** Auto Boxing, Unboxing ** Doing automatic conversion from primitive types to wrapper classes ** Autoboxing ** From the reverse wrapper class to the primitive type ** unboxing **

   Integer integer2 = Integer.valueOf(5); //No autoboxing
   int int1 = Integer1; //Unboxing
   int int2 = integer2.intValue(); //No unboxing

** Array ** Data of the same type can be handled by one variable.

The data in the array is called ** element **. Data is assigned to and referenced from the element using ** index number **.

** Index number ** starts at 0 and is the number obtained by subtracting 1 from the array.

last

I thought it would be a good review because I would put it together in my own letters. I don't fully understand modifiers yet, so I'll summarize them.

Recommended Posts

Java study memorandum
Java memorandum
JAVA memorandum
Let's study Java
Java memorandum (list)
[Java] Study notes
Java 8 study (repeatable)
Study Java Silver 1
[Java] Optional memorandum
Java Silver Study Day 1
[Java ~ Method ~] Study memo (5)
webApi memorandum in java
[Java ~ Array ~] Study memo 4
My Study Note (Java)
Java8 Silver exam memorandum
Java8 Gold exam memorandum
Study Java # 2 (\ mark and operator)
Study java arrays, lists, maps
Java Silver Study Method Memo
[Java ~ Boolean value ~] Study memo (2)
memorandum
Java study # 7 (branch syntax type)
Java
Java 3 major elements (object-oriented) memorandum
Java study memo 2 with Progate
memorandum
Java
Study Java with Progate Note 1
Summary of [Java silver study] package
[In-house study session] Java exception handling (2017/04/26)
[Study session memo] Java Day Tokyo 2017
Java study # 4 (conditional branching / if statement)
Orcacla Java Bronze SE 7/8 Qualification Study
Java study # 5 (iteration and infinite loop)
Study Deep Learning from scratch in Java.
Java learning (0)
Studying Java ―― 3
[Java] array
Summary of in-house newcomer study session [Java]
[Java] Annotation
[Java] Module
Java array
Java tips, tips
Java methods
Java method
java (constructor)
Java array
[Java] ArrayDeque
java (override)
java (method)
Java Day 2018
java (array)
Java static
Java serialization
JAVA paid
Memorandum of new graduate SES [Java basics]
Java (set)
java shellsort
MyBatis memorandum
Studying Java -5
[Java ~ Variable definition, type conversion ~] Study memo