본문 바로가기

전체 글251

반복문의 제어 break 코드 출력값 public class test { public static void main(String[] args) { for (int a=0; a 2022. 7. 14.
반복문 While 반복문 코드 출력값 public class test { public static void main(String[] args) { int i = 0; while (i 2022. 7. 14.
조건문 if(true) { System.out.println("good"); } else { System.out.println("no good"); } 출력값 good 2022. 7. 13.
연산자 (대입/산술/비교/논리) 연산자 종류 [기초연산자] 대입연산자 x = 1 산술연산자 코드 출력값 public class test { public static void main(String[] args) { int a = 100; int result = a - 1; System.out.println(result); //99 result -= 1; System.out.println(result); //98 result *= 2; System.out.println(result); //196 result /= 2; System.out.println(result); // 98 result %= 2; System.out.println(result); // 0 } } 99 98 196 98 0 비교연산자 (관계연산자) / 논리연산자 코드 출.. 2022. 7. 13.
변수의 데이터타입, 형변환(암시적,명시적) 변수의 데이터타입 * 데이터 크기 * 8bit = 1byte * 1024byte = 1killobyte * ~~~~ * 정수 데이터 타입 * byte = 1byte = -128 ~ 127 * short = 2byte = -32,768 ~ 32,767 * int = 4byte = -2,147,483,648 ~ 2,147,483,647 * long = 8byte = -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 * 데이터 타입을 선택적으로 설정해서 메모리 사용량을 절약하거나, 더 큰 사용량을 보장받을 수 있음 * long a = 2154687 * long b = 1 * 두 개 모두 차지하는 용량은 똑같다. * long a = [dddddddddd] 차지 *.. 2022. 7. 13.