Free CoreJava Programs Source codes | Examples | Video Tutorials Download

Wednesday, January 21, 2009

Minimum and Maximum Values Of Integral Data Types

/**

* Find min and max values of integral data types. Int, short, float, double,

* long

*

*

*/

public class FindMinMax {

/**

* get the min and max values of each data types

*/

public static void getMinMaxValuesOfDatatypes() {

try {

// for int

System.out.println("Integer : ");

System.out.println("\tMax Value : " + Integer.MAX_VALUE);

System.out.println("\tMin Value : " + Integer.MIN_VALUE);

// for short

System.out.println("Short : ");

System.out.println("\tMax Value : " + Short.MAX_VALUE);

System.out.println("\tMin Value : " + Short.MIN_VALUE);

// for float

System.out.println("Float : ");

System.out.println("\tMax Value : " + Float.MAX_VALUE);

System.out.println("\tMin Value : " + Float.MIN_VALUE);

// double

System.out.println("Double : ");

System.out.println("\tMax Value : " + Double.MAX_VALUE);

System.out.println("\tMin Value : " + Double.MIN_VALUE);

// for long

System.out.println("Long : ");

System.out.println("\tMax Value : " + Long.MAX_VALUE);

System.out.println("\tMin Value : " + Long.MIN_VALUE);

} catch (Exception e) {

e.printStackTrace();

}

}

/**

* execution begin from here

*

* @param args

* command line argument

*/

public static void main(String[] args) {

getMinMaxValuesOfDatatypes();

}

}

No comments:

Post a Comment

Followers