본문 바로가기

IT

Data Types

반응형

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html

Java에서 사용하는 a variable of primitive type의 각 데이터값을 보여주는 글




http://java.sun.com/docs/books/tutorial/java/nutsandbolts/ex5/MaxVariablesDemo.java

Java에서 지원하는 primitive variable의 최대최소값을 찾는 예제

/**
* MaxVariablesDemo.java is an application that compiles and runs
* under J2SE 5.0. It requires no other files.
*/

public class MaxVariablesDemo {
public static void main(String args[]) {

// integers
byte largestByte = Byte.MAX_VALUE;
short largestShort = Short.MAX_VALUE;
int largestInteger = Integer.MAX_VALUE;
long largestLong = Long.MAX_VALUE;

// real numbers
float largestFloat = Float.MAX_VALUE;
double largestDouble = Double.MAX_VALUE;

// other primitive types
char aChar = 'S';
boolean aBoolean = true;

// display them all
System.out.println("The largest byte value is " + largestByte);
System.out.println("The largest short value is " + largestShort);
System.out.println("The largest integer value is " + largestInteger);
System.out.println("The largest long value is " + largestLong);

System.out.println("The largest float value is " + largestFloat);
System.out.println("The largest double value is " + largestDouble);

if (Character.isUpperCase(aChar)) {
System.out.println("The character " + aChar + " is upper case.");
} else {
System.out.println("The character " + aChar + " is lower case.");
}
System.out.println("The value of aBoolean is " + aBoolean);
}
}

반응형