JAVA 강의(인프런)

기본형(Primitive Type) 기본형은 실제 값을 변수에 그대로 담을 수 있다. 변수에 담겨있는 값을 그대로 계산에 사용 가능. (ex int, long, boolean, double) 참조형(Reference Type) 참조형은 실제 값을 참조하고 있는 주소를 변수에 담는다. (ex 클래스, 배열) 그런데 여기서 새로 깨달은 사실이 있다. 대원칙 : 자바는 항상 변수의 값을 복사해서 대입한다. 즉 int a = 10; int b = a; System.out.println(a); System.out.println(b); a = 30; System.out.println(a); System.out.println(b); 이렇게 코드를 구성하면 결과로 이렇게 나온다. 사실 어떻게 보면 그냥 맞출 수 있는 ..
간단하게 Student라는 클래스를 만들어보자. class Student{ private String name; private int age; private int score; public Student(String name, int age, int score) { this.name = name; this.age = age; this.score = score; } public String getName() { return name; } public int getAge() { return age; } public int getScore() { return score; } } 이름, 나이, 점수를 가지는 학생 클래스를 만들어놨다. 이제 이 클래스를 이용해서 학생이라는 객체(인스턴스)를 만들어보자. publi..
indeep
'JAVA 강의(인프런)' 카테고리의 글 목록 (2 Page)