Java Core for the little ones. Part 2. Data types

Introduction

In this article, we will not be using the previously installed IDE and JDK . However, don't worry, your work was not in vain. In the next article, we will study variables in Java and actively code in IDEA . This article is also a required step. And at the beginning of your training, you will probably return to it more than once.





1998 - The pin code from my credit card is nothing more than a number. At least for us - for people. 36.5 - the temperature shown by all thermometers in different malls. For us, this is a fractional number or a floating point number. Java Core for the Little Ones is the title of this series, and we take it as text. So where am I leading. And to the fact that Java (so it is correct to pronounce, in case someone pronounces " Java "), like a person, you need to understand what she is dealing with. What type of data will you work with?





Fans of the matrix and, I hope, the rest of the readers know that at a low level, all information in a computer is represented as a set of zeros and ones. But humans, at a higher level, have high-level programming languages. They do not require working with zeros and ones, providing the ability to write code that people understand. One of such programming languages ​​is Java . Not only that, Java is a strongly typed programming language. And there are also languages ​​with dynamic data typing (for example, Java Script). But we're learning a normal programming language here, so let's not get distracted.





What does strong typing mean to us? This means that all data and each expression has a specific type, which is strictly defined. And also the fact that all data transfer operations will be checked for type compliance. Therefore, let's quickly find out what data types are represented in Java !





Primitives

In the language of Java exist 8 , outraged community , primitive data types. They are also called simple. And these are what they are:





  • Integers: byte



    , short



    , int



    , long



    ,





  • Floating point numbers: float



    , double



    ;





  • Symbols: char



    ;





  • Boolean values: boolean



    .





, , . . .





byte







. 8- c   -2^7 2^7-1. , -128 127. - . .





short







16- -2^15 2^15-1. -32768 32767. .





int







. 32 -2^31 2^31-1. , -2147483648 2147483647.





long







64- -2^63 2^63-1. -9223372036854775808 9223372036854775807. .





, ( , ).





float







32- . , double. , . , .





double







64 . double, .





char







16- 0 2^16. 0 65536. ( Unicode). , , - . char



, .





boolean







2 true false. . 1 > 10 false, 1 < 10 - true.





This is the end of the primitive data types in Java . In the next article, we will declare variables of a specific data type. Let's talk about what literals are . And we will also learn what data type casting is . In general, the next article will be very rich and informative!








All Articles