Studying Java-Part 3-Type

1.First of all

This time, I will explain Java "types".

Last time In the middle of the story, I glanced at the word "integer". This time, I will talk about this word.

2. Mold

In Java, variables have types. Last time

int number;

I wrote, but int is the type. (Number is a variable name) This type int is like a box used when dealing with integers.

There are many other types, so I will introduce them.

2.1. Primitive type

A group of types defined as reserved words in Java. Boxes that hold letters, integers, floating point numbers, etc. I hope you can imagine that there are boxes of various sizes. Floating point numbers are numbers used when dealing with decimal numbers such as 5.34 and 2.887.

Basically, if you want to use an integer, use int, If you want to use floating point numbers, I think it's a good idea to specify double.

2.1.1. Integer

Model name Description
byte -128 ~ 127
short -32768 ~ 32767
int -2147483648 ~ 2147483647
long -9223372036854775808 ~ 9223372036854775807

2.1.2. Decimal

Model name Description
float 32bit single precision floating point number
double 64-bit double precision floating point number

2.1.3. Characters

Model name Description
char Only one character

2.1.4. Boolean value

Model name Description
boolean true or false

2.2. Object type

This is the type used when a class is used as a type. I will talk about classes in a later article. There are many types, and you can create your own, so I will introduce only one.

2.2.1. String

Model name Description
String Handle strings

This type called String is a very handyman who can handle multiple characters as a string. (Note that the characters and strings are different!) This String is also a special object type in Java, and has the advantage that it can be used like the primitive type above.

3. Conclusion

What I especially want you to remember this time is int , double , char , boolean , String These are the above 5! I use it a lot ...

I'm sorry I haven't programmed. Also, I want to keep the articles as short as possible.

Next time, let's talk about "literals".

Next time → "Study Java-Part 4-Literal"

Recommended Posts

Studying Java-Part 3-Type
Studying Java-Part 0-Overview
Studying Java-Part 4-Literal
Studying Java-Part 5-Constant
Studying Java-Part 9-Scope
Studying Java-Part 10-if statement
Studying Java-Part 1-Hello World
Studying Java-Part 11-switch statement
Studying Java ―― 3
Studying Java ―― 9
Studying Java ―― 4
Studying Java -5
Pass type
Studying Java ―― 1
Studying Java # 0
Studying Java ―― 8
Studying Java ②
Directory type
Studying Java ―― 2
Studying Java ①
Studying Java -10
Human type