[ 자바 자료형 ]
public class variable_ {
public static void main(String[] args) {
// TODO Auto-generated method stub
// 자주 쓰이는 자료형
boolean stu_true = true;
boolean stu_false = false;
/* AND 연산자 */
System.out.printf("true and false => %s\n", stu_true && stu_false );
System.out.printf("false and true => %s\n", stu_false && stu_true );
System.out.printf("true and true => %s\n", stu_true && stu_true );
System.out.printf("false and false => %s\n", stu_false && stu_false );
/* 결과
true and false => false
false and true => false
true and true => true
false and false => false
*/
/* OR 연산자 */
System.out.printf("true or false => %s\n", stu_true || stu_false );
System.out.printf("false or true => %s\n", stu_false || stu_true );
System.out.printf("true or true => %s\n", stu_true || stu_true );
System.out.printf("false or false => %s\n", stu_false || stu_false );
/* 결과
true or false => true
false or true => true
true or true => true
false or false => false
*/
/* not 연산자 */
System.out.printf("not true => %s\n", !stu_true );
System.out.printf("not false=> %s\n", !stu_false );
/* 결과
not true => false
not false=> true
*/
/* 이중 부정 */
System.out.printf("not(not(true)) => %s \n", !(!stu_true));
System.out.printf("not(not(false)) => %s \n", !(!stu_false));
/* 결과
not(not(true)) => true
not(not(false)) => false
*/
}
}
============================ 문자 (char) =============================
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | // http://www.unicode.org/charts/ public class unicode_ { public static void main(String[] args) { // TODO Auto-generated method stub char han_kim = '김'; char han_jun = '준'; char han_hyeon = '현'; //=========================================== System.out.printf("%d \n", (int)(han_kim)); // 44608 System.out.printf("%c \n", (char)(44608)); // 김 System.out.printf("%c \n", 0xae40); System.out.printf("%c \n", '\uae40'); // hex(decimal(44608)) ==> 0xae40 //=========================================== System.out.printf("%d \n", (int)(han_jun)); // 51456 System.out.printf("%c \n", (char)(51456)); // 준 System.out.printf("%c \n", 0xc900); System.out.printf("%c \n", '\uc900'); // hex(decimal(51456)) ==> 0xd604 //=========================================== System.out.printf("%d \n", (int)(han_hyeon)); // 54788 System.out.printf("%c \n", (char)(54788)); // 현 System.out.printf("%c \n", 0xd604); System.out.printf("%c \n", '\ud604'); // hex(decimal(54788)) ==> 0xd604 //=========================================== } } | cs |