Sponsered Links
Categories
Sponsered Links

Java Data Types

 

Data Type is a set of permitted value on which legal operation can be perform .In java  the variety of data types available allow the programmer to select  the appropriate to need of applications.

  • Primitive (Intrinsic)
  • Non Primitive (Derived)

1. Primitive (Intrinsic) :- 1.1. Numeric

                                  1.2. Non-Numeric

        1.1. Numeric:- 1.1.1. Integer

                              1.1.2. Floating Point

        1.2. Non- Numeric:- 1.2.1. Char

                                     1.2.2. Boolean

2. Non-Primitive (Derived):- 2.1. Class

                                      2.2. Array

                                      2.3. Interface

Data Types in java are two type.

  • Primitive  Data type.
  • Non Primitive Data.

 Primitive  Data type.  Primitive  Data type are predefined  data type , which always holds the value of the same  data type.

   Primitive  Data type are two type.

  • Numeric Data Type.
  • Nonnumeric Data Type.

  1. Numeric Data Type. Numeric Data Type are two type.

1. Integer.  java support four Types of Integers

  • Byte
  • Short
  • int
  • long.

     Type

      Size

         Min value

    Max value

    Byte

      8 bit

       -128

  127

    Short

      2 byte

       -32,768

  32,767

     int

      4 byte

       -2,247,483,648

  2,247,483,647

     long

      8 byte

-9,223,372,636,854,775,808

9,223,372,636,854,775,807


 

2. Floating Point  type .   Floating Point  numbers, known as real numbers , are used when evaluating expressions that require fractional precision. For example , calculations such as square root, or transcendental such as  sine and cosine , results in a value whose precision require a floating point type. Floating Point  type two type .

  • Float Type (Single Precision).
  • Double Type ( Double  Precision).

 

      Name

        Size

      Range

      Float

        4 Byte

      1.4e-045 to 3.4e+038

       Double

        8 Byte

     6.9e-324 to  1.8e+308


     

2. Nonnumeric Type. Nonnumeric Primitive type are also two type .

  • Char
  • Boolean

1. Char:  A char is a single character, that is a letter, a digit, a punctuation mark, a tab, a space or something similar. A char literal is a single one character enclosed in single quote marks like this char Character = 'g'; In java char size 2 byte and range 0 to 65,536.

 

2. Boolean Type: Boolean Type is used when we want to test a particular condition during the execution of the program .Boolean have only two possible values ,true or false. Syntax: Boolean b;

2. Non Primitive (Reference Data Types): Reference data type  is a variable that can contain the reference or address of dynamically  created

object. The reference data types are  three type.

  • classes
  • array
  • interface

1 . class type:   Class is a collection of java method and variable .A class is define by used of the 'class' keyword. syntax:

  class class_ name {

   type instance_variable1;

   type instance_variable2;

   type instance_variable3;

   ......................

  type method_ name ( parameter list )  {

        // body  of method

        }

}

 

2. Array:  Array is a collection of similar data type of contiguous memory allocation that share a common name.    syntax

type  array_ name[];

type[] array_ name;

 

3. Interface:   An Interface is a basically a kind of class . Interfaces define only abstract methods and final fields .  syntax

    interface interface_ name {

        variable declaration;

        method declaration;

    }

 

 

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved