import java.util.Date;
import java.util.Locale;
/**
* Output:
boolean value is true, TRUE
hex value is 71ee6d51, 71EE6D51
hex value is cafe, CAFE
hex value is cafe, CAFE
hex value is 0xcafe, 0XCAFE
value: 3,140000
*/
public class MainClass {
public static void main(String args[]) throws Exception {
//boolean value is true, TRUE
System.out.printf("boolean value is %1$b, %1$B\n", true );
//hex value is b5151397, B5151397
System.out.printf("hex value is %1$h, %1$H\n", new Date() );
//hex value
System.out.printf("hex value is %1$h, %1$H\n", 0xCAFE );
//hex value
System.out.printf("hex value is %1$x, %1$X\n", 0xCAFE );
System.out.printf("hex value is %1$#x, %1$#X\n", 0xCAFE );
System.out.printf( Locale.ITALIAN, "value: %f\n", 3.14 );
}
}
|