<Git>PrintMe.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class PrintMe { public static void main(String[] args) { String name ; int age ; double height ; // 큰 범주의 실수 float weight ; // 큰 범주의 실수 String blood = "AB" ; // 변수 선언하면서 값을 대입하기 char munza ; boolean bool ; // 진위 값 name = "홍길동" ; age = 27 ; height = 175.8 ; weight = 55.8f ; // float 타입은 f를 붙여 줘라. munza = 'Z' ; bool = false ; System.out.println("이름 : " + name..
<Git>PlusMinus02.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class PlusMinus02 { public static void main(String[] args) { int x = 3, y = 5, z ; z = x++ + --y ; System.out.println("x : "+ x); //11 System.out.println("y : "+ y); //21 System.out.println("z : "+ z); //31 z += --x + y++ ; System.out.println("x : "+ x); System.out.println("y : "+ y); System.out.println("z : "+ z); } }
<Git>PlusMinus01.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class PlusMinus01 { public static void main(String[] args) { int a = 10, b = 20, c ; c = ++a + b++ ; System.out.println("a : "+ a); //11 System.out.println("b : "+ b); //21 System.out.println("c : "+ c); //31 c = a++ + --b ; System.out.println("a : "+ a); System.out.println("b : "+ b); System.out.println("c : "+ c); a = 15 ; b = 12 ; c = --a + --b ; System...
<Git>OperatorEx.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class OperatorEx { public static void main(String[] args) { int a = 3 - -2, b = 3 ; int x = (a >= b) ? 5 : (a+2); x += ++a ; int y = ++a ; y += a + --b ; char ch3 = 'D' ; int z = ch3 >= 'A' && ch3 y ? z - y : x + z ; System.out.println("result : " + result); } }
<Git>MyPrint.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; // 주석(comment) : 프로그램의 이해를 돕기 위하여 작성하는 작은 문구 // 한 줄 주석은 슬래시 2개로 작성한다. /* 목적 : 자바 1번째 프로그래밍 작성 일자 : 2022/12/29 작성자 : 홍길동 여기는 multiline 주석 영역 */ public class MyPrint { // 클래스 바디(body) // 함수=동작=역할=메소드 // main 메소드 : 프로그램 최초 시작(entry point) 하는 지점 public static void main(String[] args) { // 메소드 바디(body) // 문자열은 0개 이상의 글자의 집합 // 반드시 쌍따옴표로 포함 하여야 한다. // cf) 문자는 글자 1개를 의미하..
<Git>MyBox.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class MyBox { public static void main(String[] args) { double width ; double height ; double area ; double perimeter ; width = 10.0 ; height = 5.0 ; area = width * height ; perimeter = 2 * (width+height) ; System.out.println("사각형 넓이 :" +area); System.out.println("사각형 둘레 :" +perimeter); } }
<Git>LogicalOperator.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class LogicalOperator { public static void main(String[] args) { // hard coding System.out.println(3 >= 2); System.out.println(!(3 >= 2)); System.out.println(3 == 2); System.out.println(3 != 2); System.out.println(3.45 2) && (3>4)); int x = 3, y = 2 ; System.out.println((x != y) || (-1 > 0)); // 문자는 정수 값으로 변환되어 연산이 됩니다. System.out.println('a' > 'b'); } }
<Git> Condition02.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class Condition02 { public static void main(String[] args) { int a = 8, b = 7 ; int result = a >= b ? 5 : (a + 2) ; System.out.println("result : " + result); int x = 5 ; result = x%2 == 0 ? x+3 : x*x ; System.out.println("result : " + result); } } cf) Myjava/Condition02.java at master · nolooker/Myjava (github.com)