Java & Kotlin
[Java 객체지향] 객체지향 프로그래밍
Sue
2022. 1. 23. 21:41
객체
- 객체는 구체적, 추상적인 데이터의 단위.
- 문장에서 명사에 해당한다. ex) 회원, 주문, 학생 ...
- 멤버 변수 선언 시 camel notation으로 표기하는 것이 좋다. (가독성↑)
Student 객체 생성을 위한 클래스
public class Student {
int studentId;
String studentName;
int majorCode;
String majorName;
int grade;
}
Order 객체 생성을 위한 클래스
public class Order {
int orderId;
String buyerId;
String sellerId;
int productId;
String orderDate;
}
UserInfo 객체 생성을 위한 클래스
public class UserInfo {
String userId;
String userPassword;
String userName;
String userAddress;
int phoneNumber;
}
객체지향 프로그래밍
- 객체를 정의
- 객체의 속성은 멤버 변수로, 기능은 메소드로 구현한다.
- 객체 간 소통을 구현 한다.