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
- 형변환
- length
- 조건문
- 생성자
- Java
- for문
- switch문
- 멤버변수
- do while문
- 상속
- 메서드
- Override
- 파라미터
- 클래스
- private
- 변수
- symbol
- illustrator
- expand
- Singleton
- if문
- static
- super
- Photoshop
- Interface
- Overload
- 배열
- After effects
- while문
- 반복문
Archives
- Today
- Total
Ms'Note
Object-1 본문
멤버변수만 포함하고 있는 클래스의 작성예시
- 학생 정보를 포함하는 클래스의 작성
class Student {
/** 멤버변수의 선언 + 할당 */
// 문장을 표현할 수 있는 변수형
String name = "자바학생";
int age = 19;
}
public class Main01 {
public static void main(String[] args) {
/** 객체의 선언과 할당의 분리 */
Student std;
std = new Student();
/** 객체의 생성 (일괄지정) */
// Student std = new Student();
System.out.println("이름 : " + std.name);
System.out.println("나이 : " + std.age);
}
}
출력 결과
이름 : 자바학생
나이 : 19
Comments