본문 바로가기

JAVA/Study

22. 연산의 방향과 우선순위

//연산의 방향과 우선 순위
//오른쪽부터 연산 : ++, -- , +(부호연산자), -(부호), ~, ! , =
//왼쪽부터 연산 : +(사칙연산), - , * , /, %, >>,>>>,<<,>,>=,<,<=,==,!=...
//우선순위 :  ex) a+b && c-d 에서 a+b부터되냐 b&&c가 먼저냐
//우선순위 
// 1. ++,--, 부호+ , 부호- , ~ , ! , =
// 2. 산술연산자(* , / , % , + , -)
// 3. 시프트연산자 (>>,<<,>>>)
// 4. 비교연산자 (비교 연산자 == , != , >, >=,<, <=)
// 5. 논리연산자 (&& (And) , || (or) , ! (Not)
// 6. 삼항연산자 ( 조건 ? 참 : 거짓; )
// 7. 대입연산자 (+= , -= , *= , /= , <<= , >>= , %= )

 

 

2023.03.20 - [JAVA/Study] - 14. 산술연산자 - arithmetic operator

 

14. 산술연산자 - arithmetic operator

산술연산자 위에서부터 순서대로 더하기 뺴기 곱하기 나누기 나머지 (140을 100으로 나눈 나머지) 이다. public static void main(String[] args) { //산술연산 int a = 100; int b = 140; int c = a+b; System.out.println("a+b="

nxx5xxx.tistory.com

2023.03.20 - [JAVA/Study] - 19. 비트연산자 - bit operator

 

19. 비트연산자 - bit operator

비트연산자 public static void main(String[] args) { //비트 연산자 : 2진수 연산 &(and) , | , ^ , ~(not,보수:complement) ,>>(오른쪽시프트), > int a = 40; int b = 25; System.out.println("a & b =" +(a&b)); //and(&) 는 둘다 참(1)이여

nxx5xxx.tistory.com

 

 

19. 비트연산자 - bit operator

비트연산자 public static void main(String[] args) { //비트 연산자 : 2진수 연산 &(and) , | , ^ , ~(not,보수:complement) ,>>(오른쪽시프트), > int a = 40; int b = 25; System.out.println("a & b =" +(a&b)); //and(&) 는 둘다 참(1)이여

nxx5xxx.tistory.com

 

2023.03.20 - [JAVA/Study] - 17. 비교연산자 - Comparison operator

 

17. 비교연산자 - Comparison operator

비교연산자 public static void main(String[] args) { //비교 연산자 == , != , >, >=,b)); //15는 17보다 크다 --false(거짓) System.out.println("a>=b : " + (a>=b)); //15는 17보다 크거나 같다--false(거짓) System.out.println("a

nxx5xxx.tistory.com

2023.03.20 - [JAVA/Study] - 18. 논리연산자 - logical operator

 

18. 논리연산자 - logical operator

논리연산자 public static void main(String[] args) { //논리 연산자 : && (And) , || (or) , ! (Not) //한개씩만 쓰면 비트연산자가 됨 int a = 27; int b = 24; //AND논리 둘다 참이여야 결과가 참 System.out.println("AND논리 둘

nxx5xxx.tistory.com

2023.03.28 - [JAVA/Study] - 21. 삼항연산자

 

21. 삼항연산자

public static void main(String[] args) { //삼항 연산자 (조건 ? 참 : 거짓;) int a =37; int b =42; String result =""; result = a>b ? "a가 더 큽니다" : "b가 더 큽니다"; System.out.println(result); } } 조건 ? 참 : 거짓; 은 a 가 b보

nxx5xxx.tistory.com

2023.03.20 - [JAVA] - 15. 대입연산자 - assignment operator

 

15. 대입연산자 - assignment operator

대입연산자 public static void main(String[] args) { //대입 연산자 int a = 10; int b = 15; System.out.println("a="+a); System.out.println("b="+b); a+=3; b-=3; //a=a+3 즉 13 , b=b-3 즉 12 //10에 3을 더한값을 a에 대입하라는 뜻 // (a +

nxx5xxx.tistory.com