📘 Java vs Python vs JavaScript 문법 총정리
항목 | Java | Python | JavaScript |
변수 선언 | int x = 10;String s = "hi"; | x = 10s = "hi" | let x = 10;const s = "hi"; |
자료형 | int, double, boolean, char, String, ArrayList | int, float, bool, str, list, dict, tuple | number, string, boolean, object, array, null, undefined |
출력 | System.out.println("Hi"); | print("Hi") | console.log("Hi"); |
조건문 | if, else if, else | if, elif, else | if, else if, else |
elif 문법 | ❌ 없음 (else if) | elif x == 0: | else if (x === 0) |
pass 문법 | 없음 | pass 키워드 존재 | 없음 (빈 블록 허용 안 됨 → {} 필요) |
비교/논리 연산자 | ==, !=, &&, ` | ` | |
반복문 | for, while, foreach, do-while | for, while, for-in | for, while, for-of, for-in |
함수 정의 | public int sum(int a, int b) | def sum(a, b): | function sum(a, b)const sum = (a, b) => ... |
클래스 정의 | class Person {} + 생성자 | class Person: + __init__ | class Person { constructor() {} } |
상속 | class B extends A | class B(A) | class B extends A |
예외 처리 | try { ... } catch(Exception e) | try: ... except Exception as e: | try { ... } catch (e) {} |
리스트/배열 | int[] arr = {1,2};ArrayList<String> | [1, 2, 3] | [1, 2, 3] |
딕셔너리/객체 | Map<String, Integer>HashMap | {"key": value} | { key: value } |
람다/익명 함수 | (a, b) -> a + b | lambda a, b: a + b | (a, b) => a + b |
null / None | null | None | null, undefined |
주석 | // 한 줄/* 여러 줄 */ | # 한 줄''' 여러 줄 ''' | // 한 줄/* 여러 줄 */ |
비동기 처리 | Thread, Executor, Future | async def, await, asyncio | async/await, Promise, setTimeout |
Hello World | System.out.println("Hello"); | print("Hello") | console.log("Hello"); |
'Java' 카테고리의 다른 글
[Java] 자바 메인 함수(Main Function) (0) | 2025.03.24 |
---|---|
Java / Python / JavaScript 형변환(type casting) 정리 (0) | 2025.03.23 |
[Java] 기본 문법 정리 - 추가 (0) | 2025.03.19 |
[Java] 기본 문법 정리 - 비트 연산, 수학 라이브러리, 시간 복잡도 개념 (0) | 2025.03.19 |
[Java] 기본 문법 정리 - 이진 탐색, DFS & BFS, 동적 프로그래밍(DP) (0) | 2025.03.19 |
댓글