What is Data types?

Purpose?

I'm currently learning about JAVA and I'm getting confused about data types, so I organize what I'm understanding in this page. Also This is my English practice to explain something about programming in English. So if there's any wrong points for choosing words, welcome to comment.


First, What is a data type?

In Java, Data type should be declared when Value is declared.


Why does data type needs to be declared?

Declaring data type is not necessary actually. Some languages are not needed to declare the datatype. It's called Dynamically typed and statically typed Languages. Dynamically typed Languages doesn't need to declare the data type and Statically typed languages needs to declare the datatype.

  • Dynamically typed Languages : JavaScript / Python / Ruby /
  • Statically typed languages : C / C++ / C# / Java / Scala / Swift

There are different advantages to declare or not to declare the datatypes. I summarized it in the another article.


There are two categories of data type


JAVA is roughly divided into two data types: Primitive types and Reference types.


What is primitive types?

Primitive types are types that contain specific values such as numbers and characters. There are eight types.

PrimitivesValues
booleanTrue or False (1 Bit)
bytewhole numbers from -128 to 127(8bit)
chara word (Express 16 bit numbers of Unicode)
shortwhole numbers from -32,768 to 32,767(16 bit)
intwhole numbers from -2,147,483,648 to 2,147,483,647(16 bit)
longwhole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807(32 bit)
floatfractional numbers / Sufficient for storing 6 to 7 decimal digits(32 bit)
doublefractional numbers / Sufficient for storing 15 decimal digits(64 bit)


What is reference types?

Primitive types specifies type of values, reference types refer to objects. In this types, the programmer creates the value by themselves unlike Primitive types. (primitive types are already defined by Java).

Related posts

関連トピック