inblog logo
|
gyul
    자바 (JAVA)

    [자바 (Java)] 2-1. 일반 변수

    귤's avatar
    귤
    Feb 03, 2025
    [자바 (Java)] 2-1. 일반 변수
    Contents
    1. 정수 (4Byte)2. 실수 (8Byte)3. 참 거짓 Type4. 문자열 Type 5. 변수의 Type이 존재하는 이유
    package ex01; public class Var01 { // 1. 클래스 이름 (오브젝트) public static void main(String[] args) { // 2. 메서드 (행위) 3. main (메서드 이름) int n1 = 10; double n2 = 10.5; boolean n3 = true; // false char n4 = 'A'; System.out.println(n1); // 모니터에 ByteStream을 연결해서 괄호 안에 있는 값을 출력 System.out.println(n2); System.out.println(n3); System.out.println(n4); } }
    notion image

    1. 정수 (4Byte)

    💡
    정수의 타입 : int (4Byte)
    notion image

    2. 실수 (8Byte)

    💡
    실수의 타입 : double
    notion image

    3. 참 거짓 Type

    💡
    boolean (1Byte)
    notion image

    4. 문자열 Type

    💡
    char (2Byte)
    notion image

    5. 변수의 Type이 존재하는 이유

    💡
    메모리의 공간을 낭비하지 않기 위해!!
    notion image
     
    Share article

    gyul

    RSS·Powered by Inblog