JAVA Eclipse 20 클래스와 객체
클래스 Class
: 객체를 만들기 위한 설계도
객체지향 언어
: 코드를 객체로 만들어 재사용하겠다
-> 코드를 객체로 만드는 방법 : 클래스
클래스
클래스는 구현하고자 하는 객체의 속성과 기능들을 정의하는 설계도
따라서 속성은 변수로, 기능은 메서드(함수)로 나타낸다
클래스의 구조
class 클래스명 {
속성 (변수)
기능(메서드)
}
* 클래스명의 앞 글자는 대문자로

main이 있는 class만 public이 붙고 나머지는 붙지 않는다
클래스로 객체를 만드는 방법
자료형 참조변수 = new 클래스명 ( );
* 참조변수 : 클래스로 생성된 객체 값(인스턴스) 저장할 공간 ; 주소를 저장
* new : 메모리 할당
* 클래스명 ( ) : 클래스로 객체를 만들어라
-> 클래스로 객체 값을 만들 메모리를 할당하고, 객체 값을 생성해서 변수에 저장해라
참조변수 VS 일반변수
참조변수 : 주소를 저장하는 변수
vs
일반변수 : 값을 저장하는 공간
인스턴스
: 클래스를 통해 만들어진 형태
인스턴스화?
클래스를 통해 객체를 만드는 과정
클래스의 사용
객체 내 값을 사용하는 방법
객체변수.필드명
객체 안의 값을 사용한다 : 객체 내 변수, 메서드를 사용한다는 것
변수의 사용 : 변수에 값 저장, 변수의 값의 연산, 출력, ...
메서드의 사용 : 메서드 호출
ex1.

출력화면

ex2.

출력화면

클래스로 여러 객체 만들기
클래스는 객체를 만드는 틀이므로, 여러 개의 값을 만들 수 있다
ex3.

출력화면

JAVA Eclipse 01 프로그램, 프로그래밍, 기계어, JAVA
https://developernew.tistory.com/63
JAVA Eclipse 02 자바 출력메서드와 입력메서드
https://developernew.tistory.com/71
JAVA Eclipse 03 변수, 자료형, 형변환, 변수의 상수화
https://developernew.tistory.com/74
JAVA Eclipse 04 연산자 정의, 연산자 종류, 연산자 우선순위
https://developernew.tistory.com/78
JAVA Eclipse 05 논리연산자, 비트연산자
https://developernew.tistory.com/80
JAVA Eclipse 06 기타연산자 - 삼항연산자, 대입연산자, 복합대입연산자, instanceof
https://developernew.tistory.com/84
JAVA Eclipse 07 제어문 : 조건문
https://developernew.tistory.com/88
JAVA Eclipse 08 제어문 : 조건문 switch + Random 클래스
https://developernew.tistory.com/93
JAVA Eclipse 09 제어문 : 반복문 for
https://developernew.tistory.com/102
JAVA Eclipse 10 제어문 : 반복문 while, do-while
https://developernew.tistory.com/103
JAVA Eclipse 11 제어문 : 반복문의 break, continue
https://developernew.tistory.com/106
JAVA Eclipse 12 배열 : 배열의 개념 및 사용
https://developernew.tistory.com/107
JAVA Eclipse 13 배열 : 예제풀이, 로또번호 생성기
https://developernew.tistory.com/115
JAVA Eclipse 14 배열 : 다차원배열
https://developernew.tistory.com/117
JAVA Eclipse 15 배열의 복제, for ~ each문
https://developernew.tistory.com/120
JAVA Eclipse 16 카페 주문 시스템(키오스크) 배열과 제어문(반복문, 조건문)으로 풀기
https://developernew.tistory.com/124
JAVA Eclipse 17 method 메서드(메소드)
https://developernew.tistory.com/126
JAVA Eclipse 18 메서드(메소드) 오버로딩
https://developernew.tistory.com/133
JAVA Eclipse 19 객체지향 언어
https://developernew.tistory.com/135