/** * 자바의 흐름제어 : 삼항연산자, if~else, */ public class TestIfElse { public static void main(String[] args) { //if (조건식) { // true or false //참일 경우 수행 //} int num = 30; if (num > 30) { System.out.println("num 은 30보다 크다"); } if (num > 20) { System.out.println("num 은 20보다 크다"); } //if (조건식) { //참일경우 수행 //} else { //거짓일경우 수행 //} num = 30; if (num > 30) { System.out.println("30보다큼"); } else { System.out.pr..
JAVA
/** * 연산자 Operator : 기호 * 피연산자의 값을 가공 * 피연산자의 개수에 따라 구분:단항연산자,이항연산자,삼항연산자,대입연산자 */ public class TestOperator { public static void main(String[] args) { // 단항연산자 : + - ++ -- ! ~ int a = 3; System.out.println(-a); // 부호연산자 + - a = 3; // 증감연산자 a++; // a = a + 1; System.out.println(a); a = 3; System.out.println(++a); //4 전치증감연산자 : 증감 후 참조 System.out.println(a); //4 a = 3; System.out.println(a++); //..
/** *변수 Variable *: 데이터를 저장할 수 있는 기억공간 */ public class TestVariable { public static void main(String[] args) { // 기본형 타입 8가지 // 정수형 : byte(1), short(2), "int(4)", long(8) // 실수형 : float(4), "double(8)" // 논리형 : boolean(1) // 문자형 : char(2) int a; // 변수 선언 a = 10; // 변수의 초기화 : 값을 처음 할당 a = 20; // 마지막으로 저장된 값만 기억함 System.out.println(a); int b = 30; // 변수 선언, 초기화를 한번에 byte by = 6; short sh = 7; long..