Data Types in Java

Java is a strongly typed programming language. Therefore, you have to mention the type of value before compilation otherwise, you will get a compile-time error.

There are mainly two type of data:

  • Primitive data type
  • Non- primitive data type

Primitive data type are divided into following parts:

  • Integer
  • byte : size 1byte | range (-128 to 127)
  • short : size 2bytes | range (-32768 to 32767)
  • int : size 4 bytes | range (-2147483648 to 2147483647)
  • long : size 8 bytes | range (-9223372036854775808 to 9223372036854775807)
  • Decimal Numbers
  • float: size 4 bytes

float f = 3.3333333f        

Float values must be created with the suffix F or f. When after decimal you add digit upto 7 then it comes under float data type. but as soon as number goes beyond 7 digit then our value comes under double.

  • double: size 8 bytes

double d = 3.33333333d        

  • char: size : 2bytes

we can store alphabates, numerical, special character.

  • boolean: size: 1 bit

In java there is no concept of range to boolean datatype.

要查看或添加评论,请登录

Devidas Sabale的更多文章

  • All About Array

    All About Array

    What is Array: Array is group of primitive data, group of objects. Array is group of similar data (homogeneous data).

    1 条评论
  • Var arg method in Java

    Var arg method in Java

    Prior to learning this concept, I used to think that we could not change the syntax of the main method. But we can make…

  • What is literal in Java?

    What is literal in Java?

    Literals are the constant values that can be assigned to a variable. Types of literals: Decimal Literal Octal Literal…

    2 条评论
  • Why Java is not a fully object oriented programming language?

    Why Java is not a fully object oriented programming language?

    Here are reasons: Primitive Data Types: In Object Oriented Programming everything should be object. But in Java there…

社区洞察

其他会员也浏览了