Ms'Note

Method-4 본문

IT/└▶Example Coding.JAVA

Method-4

Jelly_B 2020. 8. 1. 20:12

다른 메서드를 호출하는 메서드

  • f1()은 f2()를 호출하고 있다.
public class Main04 {
    public static void main(String[] args) {
        System.out.println(f2(100));
    }
    
    public static int f1(int x) {
        return x + 1;
    }
    
    public static int f2(int x) {
        // 다른 메서드의 호출
        return f1(x) + 1;
    }
}

 

 

출력 결과

102

'IT > └▶Example Coding.JAVA' 카테고리의 다른 글

Object-2  (0) 2020.08.01
Object-1  (0) 2020.08.01
Method-3  (0) 2020.08.01
Method-2  (0) 2020.08.01
Method-1  (0) 2020.08.01
Comments