Sunday, January 31, 2016

DataTypeExample1

package LearnJava;

public class DataTypeExample1 {




double d = 8976.98;
float f = 987.923F;
long l = 11111111111L;
int i = 1111111111;
short s;
byte by;
char c = 'A';
boolean b = false;



double doubledefaultValue;
float floatdefaultValue;
long longdefaultValue;
int intdefaultValue;
short shortdefaultValue;


//double>float>long>int>short>byte>char>boolean;


/**
* double:
* double data type is a double-precision 64-bit IEEE 754 floating
* point.
*
* This data type is generally used as the default data type for decimal
* values, generally the default choice.
*
* Double data type should never be used for precise values such as
* currency.
*
* Default value is 0.0d.
*
* Example: double d1 = 123.4
*
* @param args
*/

/**
* float:
* Float data type is a single-precision 32-bit IEEE 754 floating
* point.
*
* Float is mainly used to save memory in large arrays of floating point
* numbers.
*
* Default value is 0.0f.
*
* Float data type is never used for precise values such as currency.
*
* Example: float f1 = 234.5f

*/


/**
* For long
* Long data type is a 64-bit Minimum value is
* -9,223,372,036,854,775,808.(-2^63) Maximum value is
* 9,223,372,036,854,775,807 (inclusive). (2^63 -1)
*/

/**
* For Int
* Int data type is a 32-bit Minimum value is -
* 2,147,483,648.(-2^31) Maximum value is 2,147,483,647(inclusive).(2^31 -1)
*/


/**
* boolean:
* boolean data type represents one bit of information.
*
* There are only two possible values: true and false.
*
* This data type is used for simple flags that track true/false conditions.
*
* Default value is false.
*/

/**
* char:
* char data type is a single 16-bit Unicode character.
*
* Minimum value is '\u0000' (or 0).
*
* Maximum value is '\uffff' (or 65,535 inclusive).
*
* Char data type is used to store any character.
*
* Example: char letterA ='A'
*
* @param args
*/

public static void main(String[] args) {
// TODO Auto-generated method stub

DataTypeExample1 obj = new DataTypeExample1();
System.out.println("long value is:-"+obj.l);
System.out.println("float value is:-"+obj.f);
System.out.println("double value is:-"+obj.d);
System.out.println("char valus is:-"+obj.c);
System.out.println("********************************");

System.out.println("Double default value is:-"+obj.doubledefaultValue);
System.out.println("Float default value is:-"+obj.floatdefaultValue);
System.out.println("Long default value is:-"+obj.longdefaultValue);
System.out.println("Integer default value is:-"+obj.intdefaultValue);
System.out.println("Short default value is:-"+obj.shortdefaultValue);
System.out.println("boolean default value is:-"+obj.b);
System.out.println("********************************");



System.out.println("Double size is:-"+Double.SIZE);
System.out.println("Float size is:-"+Float.SIZE);
System.out.println("Long size is:-"+Long.SIZE);
System.out.println("Integer size is:-"+Integer.SIZE);
System.out.println("Short size is:-"+Short.SIZE);
System.out.println("Byte size is:-"+Byte.SIZE);
System.out.println("Character size is:-"+Character.SIZE);

System.out.println("**-------*********************************");
System.out.println("Double MIN_VALUE is "+Double.MIN_VALUE);
System.out.println("Double MAX_VALUE is "+Double.MAX_VALUE);

System.out.println("Float MIN_VALUE is "+Float.MIN_VALUE);
System.out.println("Float MAX_VALUE is "+Float.MAX_VALUE);

System.out.println("Long MIN_VALUE is "+Long.MIN_VALUE);
System.out.println("Long MAX_VALUE is "+Long.MAX_VALUE);

System.out.println("Integer MIN_VALUE is "+Integer.MIN_VALUE);
System.out.println("Integer MAX_VALUE is "+Integer.MAX_VALUE);



}

}

No comments:

Post a Comment