Breaking

Search This Blog

Wednesday 29 August 2018

Beginning in java :Data Types in Java

Beginning Java: Data types, Variables, Arrays  And Data Types in Java 

 

Java is a simple, object oriented, high performance  secure language. because java not use a pointers.

*data types in java is approx same as c,c++ language. 

Data types in Java are classified into two types:
  1. 1.Primitive—which include Integer, Character, Boolean, and Floating Point.
  2. 2.Non-primitive—which include Classes, Interfaces, and Arrays.
1.Primitive

primitive data type are pre-define data types. There are following four differen types of data types.  

1. Integer

Integer types can hold whole numbers such as 1,2,3,5895 and −96. The size of the values that can be stored depends on the data type(integer type) that we choose. 
there are  four sub types
default values :\u00
Type          Size  
byte  1 byte
short2 bytes
int4 bytes
long8 bytes


2 Character

It stores character constants in the memory. It assumes a size of 2 bytes, but basically it can hold only a single character because char stores unicode character sets. It has a minimum value of  0 and a maximum value of 65,535 inclusive.

3.Floating Point

Floating point data types are used to represent numbers with a fractional part. Single precision floating point numbers occupy 4 bytes and Double precision floating point numbers occupy 8 bytes.
default values :0.0f
 There are two subtypes:
TypeSize
float4 bytes
double8 bytes(default values :\u00)

4. Boolean

Boolean data types are used to store values with two states: true or false.

default values :0.1


2.Non-primitive:




Non-primitive data type are user define data types. There are following three differen types of data types. 

Non primitive data types are called reference types in Java and they refer to an object. They are created by the programmer and are not defined by Java like primitives are. A reference type references a memory location where the data is stored rather than directly containing a value.
they are three types
1. Array
2. class
3.Interface


2 comments:

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();