자바연산자
[Java] 논리 NOT 연산자
1. 논리 NOT 연산자 ( !=) (4) 에서 알아봤던 내용에 논리 not 연산자가 사용되었다. !A : !는 A가 참이면 거짓으로, A가 거짓이면 참으로 바꿔준다. boolean 관계 연산자 (1) 예문 1 1 2 3 4 5 6 7 8 9 package Not; public class NotTest1 { public static void main(String[] args) { boolean result = !true; System.out.println(result); } } Colored by Color Scripter cs - 출력값 false (2) 예문 2 1 2 3 4 5 6 7 8 9 package Not; public class NotTest2 { public static void main..
[Java] continue 와 break 예문 & 논리 OR연산자, 논리 AND 연산자
1. continue 와 break 를 사용한 예문 (1) break 사용 예문 for(i=1;true;i++) 반복문 설정하고 ' 1+2+3+ ... ' 순차적으로 더했을 때 값이 최초로 5000을 넘는 수를 break를 통해 구현하기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 package ContinueAndBreak; public class ContinueAndBreakTest4 { public static void main(String[] args) { int i=0, sum=0; for(i=1; true; i++) { sum+=i; if(sum>5000) { System.out.println(sum); break; } } } } Colored by Color Scri..