Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- t삭제(delete)
- 조건문#중첩반복문#기본
- springboot
- 문자와숫자#특수기호
- sprinboot
- 물
- /자바 #/간단한프로그램
- 자바#게임
- CRUD
- 자바#제네릭스기본#List개념
- 자바
- Update
- 절차지향
- 오버라이딩
- 탐사수
- jpa
- 쿠팡
Archives
- Today
- Total
간단
초기화와 생성자 본문
728x90
1. 객체 초기화 : 필요한 설정 작업을 할 수 있다.
2.독립적인 여러 개체를 만들 수 있다.
3.코드의 품질 향상 등등
public class C1 {
int left;
int right;
public C1(int left, int right) { //생성자 초기화
//어떠한 메소드 보다도 먼저 실행이 된다.
this.left = left;
this.right = right;
}
void sum() {
System.out.println(this.left + this.right);
}
public static void main(String[] args) {
C1 c = new C1(10, 20); // C1() : 생성자
c.sum(); // 30 실행
}
}