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.
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.
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.
Model name | Description |
---|---|
byte | -128 ~ 127 |
short | -32768 ~ 32767 |
int | -2147483648 ~ 2147483647 |
long | -9223372036854775808 ~ 9223372036854775807 |
Model name | Description |
---|---|
float | 32bit single precision floating point number |
double | 64-bit double precision floating point number |
Model name | Description |
---|---|
char | Only one character |
Model name | Description |
---|---|
boolean | true or false |
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.
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.
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