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 |
Tags
- mybatis
- layout
- 기본
- oracle
- 이클립스
- Graphic
- OGNL
- 배열
- paint
- 생성자
- AWT
- struts2
- Menu
- 어노테이션
- 메소드
- Spring
- 안드로이드
- 국제화
- JavaScript
- 에러페이지
- 오버로딩
- Java
- 예외처리
- Android
- 메서드
- JSP
- Eclips
- 전화걸기
- HTML
- 클래스
Archives
- Today
- Total
note
클래스로 자동차 만들기 본문
class Car{//클래스로 자동차
//멤버 변수
int speed;
int direction;
}
public class CarTest {
public static void main(String[] args){
Car c = new Car();
c.speed = 10;
c.direction=1;
System.out.println("speed : "+ c.speed);
System.out.println("direction : "+ c.direction);
System.out.println("Car 객체 : "+c);
System.out.println("===================");
Car c2 = new Car();
System.out.println("speed : "+ c2.speed);
System.out.println("direction : "+ c2.direction);
System.out.println("Car 객체 : "+c2);
}
}
speed : 10
direction : 1
Car 객체 : Car@110003
===================
speed : 0
direction : 0
Car 객체 : Car@17e4ca
'자바 > 클래스&객체' 카테고리의 다른 글
클래스 기본3 (0) | 2011.12.16 |
---|---|
클래스 기본2 (0) | 2011.12.15 |
클래스로 구구단 만들기 (0) | 2011.12.15 |
클래스로 사칙연산2 (0) | 2011.12.15 |
클래스로 사칙연산 (0) | 2011.12.15 |