Monday, June 25, 2007

A program to print limits of the primitive types

This Java program prints the limits of primitive types (e.g. byte, short, int ...) in Java:

public class PrintLimits
{

public PrintLimits()
{
}

public static void main(String args[]) {

System.out.println("Min byte value = " + Byte.MIN_VALUE);
System.out.println("Max byte value = " + Byte.MAX_VALUE);
System.out.println("Min short value = " + Short.MIN_VALUE);
System.out.println("Max short value = " + Short.MAX_VALUE);
System.out.println("Min int value = " + Integer.MIN_VALUE);
System.out.println("Max int value = " + Integer.MAX_VALUE);
System.out.println("Min float value = " + Float.MIN_VALUE);
System.out.println("Max float value = " + Float.MAX_VALUE);
System.out.println("Min double value = " + Double.MIN_VALUE);
System.out.println("Max double value = " + Double.MAX_VALUE);
}
}

source: http://java-tips.org

No comments: