package com.study.javastudy.study;

public class TypeCastingExam {
    public static void main(String[] args) {
        int x = 50000;
        long y = x;

        long x2 = 5;
        //int y2 = x2; // long 타입을 int 타입에 담으려 하면 오류남
        int y2 = (int) x2; // 형변환을 하면 오류가 안남
    }
}

 

'자바 기초' 카테고리의 다른 글

비교연산자  (0) 2024.01.26
연산자와 연산  (0) 2024.01.26
기본형 데이터 타입  (0) 2024.01.26
상수  (0) 2024.01.26
변수  (2) 2024.01.26

+ Recent posts