package week02;
public class w08 {
public static void main(String[] args) {
int x=2;
int y=9;
int z=10;
boolean result = x < y && y < z; //true && true = true
System.out.println(result);
}
}y가 x보다 크고 z가 y보다 큰게 맞기 때문에 모두 true가 성립하고 && 조건에 맞기 때문에 결과 값은 true이다
result = x + 10 < y && y < z; //false && true = false
System.out.println(result);
x + 10 = 12, y=9 : false / y = 9, z =10 : true / false && true 의 결과는 false
result = x + 2 * 3 > y;
System.out.println(result); //false
x + 2 3에서 2 3 은 6, x + 6은 8 / y는 9이기 때문에 false
result =(x + 2) * 3 > y; //true
System.out.println(result);
x + 2는 4, 4 * 3은 12 / y는 9이기 때문에 true
총 코드
package week02;
public class w08 {
public static void main(String[] args) {
int x=2;
int y=9;
int z=10;
boolean result = x < y && y < z; //true && true
System.out.println(result);
System.out.println("--------");
result = x + 10 < y && y < z; //false && true
System.out.println(result);
System.out.println("--------");
result = x + 2 * 3 > y; //false
System.out.println(result);
System.out.println("--------");
result =(x + 2) * 3 > y; //true
System.out.println(result);
}
}

package week02;
public class w09 {
public static void main(String[] args) {
short x = 10;
int y = 20;
int z = x + y; //30
long lx = 30L;
long lz = z + lx; //60
float fx = x; //10
float fy = y; //20
float fz = z; //30
System.out.println(lz);
System.out.println(fx);
System.out.println(fy);
System.out.println(fz);
}
} 
(3 << 2) //12 와 (3 << 1) //6 을 통해 비트 예시 알아보기
package week02;
public class w10 {
public static void main(String[] args) {
System.out.println(3 << 2);
System.out.println(3 << 1);
}
}

3을 2진수로 표현하면 2 1 1 → 1 1 2진수 / 2는 1 0 2진수

3 << 2 : 3을 비트연산으로 오른쪽으로 2 만큼 옮기세요

3 <<1 : 3을 비트연산으로 오른쪽으로 1 만큼 옮기세요

// 조건문
boolean flag = true;
if (flag) {
System.out.println("flag 값은 true 입니다."); // flag 값은 true 입니다. 출력
}// 조건문 with else
boolean flag = false;
if (flag) {
System.out.println("flag 값은 true 입니다."); // 미출력
} else {
System.out.println("flag 값은 false 입니다."); // flag 값은 false 입니다. 출력
}if true인 경우
package week02;
public class w11 {
public static void main(String[] args) {
boolean flag = true;
if (flag) {
//true인 경우
System.out.println("값은 true");
}
}
}

if false인 경우
package week02;
public class w11 {
public static void main(String[] args) {
boolean flag = false;
if (flag) {
//true인 경우
System.out.println("값은 true");
}
}
}

false일 때 값을 실행 시키고 싶다 → else 활용
package week02;
public class w11 {
public static void main(String[] args) {
boolean flag = false;
if (flag) {
//true인 경우
System.out.println("값은 true");
}
else {
//false인 경우
System.out.println("값은 false");
}
}
}

1 ≠ 1 1은 1이 아니다의 if문
if (1 != 1) {
//true인 경우
System.out.println("값은 true");
}
else {
//false인 경우
System.out.println("값은 false");
}

if else if else (더 확장된 개념)
if () {
} else if () {
} else {
}else if 무한으로 확장 가능
if - else if - else
int number = 2;
if (number == 1) {
System.out.println("number값은 1입니다.");
} else if (number == 2) {
System.out.println("number값은 2입니다.");
} else {
System.out.println("number값은 몰라용");
} 

package week02;
public class w12 {
public static void main(String[] args) {
boolean flag = true;
int number = 2;
if(flag) {
if (number == 1) {
System.out.println("flag 값은 true고, number 값은 1입니다");
} else if (number == 2) {
System.out.println("flag 값은 true고, number 값은 2입니다");
} else {
System.out.println("flag 값은 true고, number 값은 몰라용");
}
} else {
if (number == 1) {
System.out.println("flag 값은 false고, number 값은 1입니다");
} else if (number == 2) {
System.out.println("flag 값은 false고, number 값은 2입니다");
} else {
System.out.println("flag 값은 false고, number 값은 몰라용");
}
}
}
} 
Scanner는 import java.util.Scanner; 확인
Scanner sc = new Scanner(System.in);
A 입력해서 커서가 깜빡이는 효과 (입력해 달라는 효과)
//A에게 값 입력받기
System.out.println("A 입력 : ");
String aHand = sc.nextLine();
두 개의 값을 비교하는 메소드 -> Object.equals(좌, 우)
가위 바위 보!
package week02;
import java.util.Objects;
import java.util.Scanner;
public class w13 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//A에게 값 입력받기
System.out.println("A 입력 : ");
String aHand = sc.nextLine();
//B에게 값 입력받기
System.out.println("B 입력 : ");
String bHand = sc.nextLine();
//두 개의 값을 비교하는 메소드 -> Object.equals(좌, 우)라는 메소드
//왼쪽과 오른쪽이 값이 같으면 true로 반환
//아니면 false로 반환
if (Objects.equals(aHand, "가위")){
if (Objects.equals(bHand, "가위")) {
System.out.println("A와 B는 비겼다");
} else if (Objects.equals(bHand, "바위")){
System.out.println("B가 이겼다");
} else if ((Objects.equals(bHand, "보"))){
System.out.println("A가 이겼다");
} else {
System.out.println("B가 이상한 값을 입력했다");
}
} else if (Objects.equals(aHand, "바위")) {
if (Objects.equals(bHand, "가위")) {
System.out.println("A가 이겼다");
} else if (Objects.equals(bHand, "바위")){
System.out.println("A와 B는 비겼다");
} else if ((Objects.equals(bHand, "보"))){
System.out.println("B가 이겼다");
} else {
System.out.println("B가 이상한 값을 입력했다");
}
} else if (Objects.equals(aHand, "보")){
if (Objects.equals(bHand, "가위")) {
System.out.println("B가 이겼다");
} else if (Objects.equals(bHand, "바위")){
System.out.println("A가 이겼다");
} else if (Objects.equals(bHand, "보")){
System.out.println("A와 B는 비겼다");
} else {
System.out.println("B가 이상한 값을 입력했다");
}
} else {
System.out.println("A가 이상한 값을 입력했다");
}
}
}


오류?

오류 해결
