목록주니어개발자 (2)
지니의 연대기
블로그 작업장 this 예약어 this는 간단하게 생성된 인스턴스 스스로를 가리키는 예약어 이다. class Birthday { int day; int month; int year; public void setYear(int year){ this.year = year; // bday.year = year과 같음. } public void showThis(){ System.out.println(this); // System.out.println(bday) 와 같음. } } public class ThisExample{ public static void main(String[] args) { Birthday bDay = new Birthday(); bDay.setYear(1996); System.out.pr..
Cpt05 객체 지향 프로그래밍 객체 객체란 눈에 보이는 모든 사물이다. 사람, 자동차, 연필, 건물 등등 객체 지향 프로그래밍은 이러한 객체들로 하여금 상호작용을 통해 프로그래밍 하는 프로그래밍 방식이다. 클래스 클래스란 객체를 만드는 틀이다. 클래스를 통해 실제로 생성 된 객체는 인스턴스라고 부른다. 클래스 예시 public class Student { int studentId; String studentName; int grade; String address; } // 클래스를 선언하고 // 그안에 클래스의 맴버 변수를 선언 메서드 예를 들어 학생이 사는 곳을 출력하는 클래스 내부 함수를 만들어 본다면 public class Student { int studentId; String studentNa..