일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- jsp
- request
- c++
- windows
- beans
- WebProgramming
- Kafka
- java
- System
- CLASS
- array
- 악성코드
- 투자
- CSS
- JavaScript
- 윈도우즈
- UTF-8
- algorithm
- 자료구조
- API
- 포인터
- function
- Call-by-reference
- C
- meta
- HTML
- Sort
- 노드
- query
- OOP
Archives
- Today
- Total
hahahia
[Java] 생성자 예제 본문
Java 생성자 예제
/** * Created with IntelliJ IDEA. * User: hahahia * Date: 12. 10. 13 * Time: 오후 5:25 * To change this template use File | Settings | File Templates. */ public class TopConstructor { private String name = null; private String address = null; private int age = 0; public TopConstructor(){ name = "이름 없음" ; address = "주소 없음" ; age = 0; } public void setData(String n, String a, int g){ name = n; address = a; age = g; } public String getData(){ String str = name + ", " + address + ", " + age; return str; } public static void main(String[] args){ TopConstructor tc = new TopConstructor(); String s; s = tc.getData(); System.out.println(s); tc.setData("Minhwa", "Incheon", 25); s = tc.getData(); System.out.println(s); } }
'Language > Java' 카테고리의 다른 글
LocalDate / YearMonth 를 이용하여 특정 월의 일 수, 마지막 날 구하기 (0) | 2019.12.08 |
---|---|
[Java] 상속을 이용한 프레임 창 띄우기 예제 (0) | 2012.10.13 |
Comments