package hakwon3;
class Plus{
int a;
int Plusone(int a) {
a++;
return a; // 꼭 return a를 해줘야 a++된 값이 출력된다!
}
}
public class Practice {
public static void main(String[] args) {
Plus firstsample = new Plus();
int firstresult = firstsample.Plusone(31);
Plus secondsample = new Plus();
int secondresult = secondsample.Plusone(88);
System.out.println(firstresult);
System.out.println(secondresult);
}
}
32
89
'Language > JAVA' 카테고리의 다른 글
| JAVA 연습문제 (객체 클래스 메서드, split) (0) | 2023.07.21 |
|---|---|
| JAVA '==' vs 'equals' (0) | 2023.07.21 |
| JAVA 객체(5) - 메서드에서 빠져나가기 (0) | 2023.07.21 |
| JAVA 객체(4) - 메서드 두 번째 (0) | 2023.07.20 |
| JAVA 객체(3) - 연습문제 (0) | 2023.07.18 |