๐ 2023๋ 12์ 5์ผ
[java 1์ผ์ฐจ]
Sun Microsystems์ฌ์ James Gosling์ java
์ปดํ์ผ์ธ์ด(๋น ๋ฆ) vs ์ธํฐํ๋ฆฌํฐ ์ธ์ด(๋๋ฆผ)
.java -> ์ปดํ์ผ๋ฌ(javac) -> .class -> ์ธํฐํ๋ฆฌํฐ(java, jvm) -> ์คํ
์ปดํ์ผ์๋ฌ : ๋ฌธ๋ฒ์ ์๋ชป ์์ฑํด ํ๋ก๊ทธ๋จ์ ์ปดํ์ผํ ์ ์๋ ์๋ฌ
๋ฐํ์์๋ฌ : ํ๋ก๊ทธ๋๋จธ์ ์ค๊ณ ๋ฏธ์์ผ๋ก ํ๋ก๊ทธ๋จ ์คํ ์ค ๋ฐ์ํ๋ ์๋ฌ
import java.util.Scanner; public class C01_InputOutput { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); System.out.println(a); } }
- ์ ์ํ
byte num1 =127 int a1 = 10;
- ์ค์ํ
float num3 = 1.123456789f; double num4 = 1.123456789;
- ๋ฌธ์ํ
char my_char = '๊ฐ';
- ๋ ผ๋ฆฌํ
boolean my_bool = true;
- null
null์ ์ฐธ์กฐํ ํ์ ์ ๊ธฐ๋ณธ ๊ฐ์ด๋ค.
// ์ฐ์ ์ฐ์ฐ์ int num1 = 8, num2 = 3; System.out.println("num1 + num2 = "+ (num1+num2)); System.out.println("num1 - num2 = "+ (num1-num2)); System.out.println("num1 * num2 = "+ (num1*num2)); System.out.println("num1 / num2 = "+ (num1/(double)num2)); System.out.println("num1 % num2 = "+ (num1%num2)); // ๋์ ์ฐ์ฐ์ int n1 = 7, n2 = 7, n3 = 7; n1 = n1-3; n2 -= 3; n3 =- 3; int n4 = 10, n5 = 10; n4 /= 3; n5 %= 3; // ์ฆ๊ฐ ์ฐ์ฐ์ int a = 5; int b = a++; System.out.println(a); System.out.println(b); // ๋ ผ๋ฆฌ ์ฐ์ฐ์ int num01 = 10, num02 = 20; boolean result1, result2; result1 = 5<num01 && num01<20; result2 = 10<num02 || num02<30; System.out.println(result1); System.out.println(result2); System.out.println(!result2); // ๋นํธ ์ฐ์ฐ์ System.out.println(2 & 1); System.out.println(2>0 & 3>0); n1 = 5; // 0101 n2 = 6; // 0110 System.out.println(n1 & n2); // 4 = 0100 System.out.println(n1 | n2); // 7 = 0111 System.out.println(n1 ^ n2); // 3 = 0011 System.out.println(~n1); // ์ฒซ์งธ์๋ฆฌ๊ฐ ์/์์ธ๋ฐ, ์์ผ๋ก ๋ณํ // << >> , ๊ณฑ์ ๊ณผ ๋๋์ ์ ํจ๊ณผ System.out.println(n1 << 1); System.out.println(n2 >> 1);