Data Types In Java

Primitive Data Types and Referenced Datatypes

Premitive Data Types:
 There are  eight primitive data types in Java
"boolean"  :- the type whose values are either true or false
"char" :- the character type whose values are 16-bit Unicode characters (only single character ).
ex: 'a'
The arithmetic types:
The integral types:
"byte" (-128 .. 127 numeric range values)
"short"(-32,768 .. 32,767 numeric range values)
"int"(-2,147,483,648 .. 2,147,483,647 numeric range values )
"long"(-9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807 numeric range values )
The floating-point types
"float"
"double"


Referenced Datatypes:
Referenced DataType is a varible defined  of a class
for example : "String" is a class given in "java.lang" package
if we want to represent a string (a group of characters) i.e"abcdef"

we need to define a variable of String class type as below
String str = "abc";

ReferenceType for custom class:
if we have a class Defined as bellow
class Vehicle{
int vehicleNo;
String vehicleName;
String vehicleCompany;
}

if we want to hold a vehicle we can hold by help of reference type as bellow
Vehicle veh;
syntax:
class-name ref-variable ;

Default value:
default value means if we define a variable in a class and not assigned any value then there will be one value assigned to that variable that is default value , it is varying from type to type below are default values of every data type.





"String or any reference (predefined class or our own class)" Variable will have "null" as default value




Comments

Popular posts from this blog

Purpose of "class" keyword

What is java?