객체
- 객체는 구체적, 추상적인 데이터의 단위.
- 문장에서 명사에 해당한다. 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;
}
객체지향 프로그래밍
- 객체를 정의
- 객체의 속성은 멤버 변수로, 기능은 메소드로 구현한다.
- 객체 간 소통을 구현 한다.
'Java & Kotlin' 카테고리의 다른 글
[Java 객체지향] 함수와 메소드 (0) | 2022.01.24 |
---|---|
[Java 기초] break문, continue문 (0) | 2022.01.21 |
[Java 기초] 반복문 (0) | 2022.01.20 |