- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChapter11.java
More file actions
Latest commit
28 lines (22 loc) · 777 Bytes
/
Copy pathChapter11.java
File metadata and controls
28 lines (22 loc) · 777 Bytes
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
packagejavastudy;
classRetrun{
//반환값이 있고 매개변수는 없는는 경우
StringgetName(){
return"홍길동";//호출한 곳으로 반환값을 돌려준다.
}
//반환값이 있고 매개변수가 없는 경우
intgetAge() {
return30;//호출한 곳으로 반환값을 돌려준다.
}
}
publicclassReturnEx {
publicstaticvoidmain(String[] args) {
Retrunobj = newRetrun();
Stringname=obj.getName();//호출도 하고 결과값도 가지고 있다
intage = obj.getAge();
System.out.println("name = "+name);
System.out.println("age = "+age);
System.out.println("name = "+obj.getName());
System.out.println("age = "+obj.getAge());
}
}