inblog logo
|
gyul
    자바 (JAVA)

    [자바 (JAVA)] 47. Wrapper

    귤's avatar
    귤
    Feb 18, 2025
    [자바 (JAVA)] 47. Wrapper
    Contents
    ❗ 중요 !!
    💡
    ✅ Wrapper를 쓰면 null를 저장할 수 있다.
    ✅ Wrapper를 쓰면 함수를 저장할 수 있다.
    ❗ Long d = 10 L
    package ex17; class User { private Long no; private String name; private Integer money; public User(Long no, String name, Integer money) { this.no = no; this.name = name; this.money = money; } public Long getNo() { return no; } public String getName() { return name; } public Integer getMoney() { return money; } } public class Wrap01 { public static void main(String[] args) { // 1. 회사 운영 User user = new User(1L, "홍길동", null); } }
    package ex17; public class Wrap02 { public static void main(String[] args) { String s1 = "10"; Integer i1 = Integer.parseInt(s1); // 문자를 숫자로 / 문자 -> 숫자 Integer i2 = 20; String s2 = i2 + ""; String s3 = i2.toString(); } }

    ❗ 중요 !!

    int → Integer
    char → Character
    long → Long n = 10L
    Share article

    gyul

    RSS·Powered by Inblog