Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
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 31
Tags
more
Archives
Today
Total
관리 메뉴

개발새발

#재귀 본문

자바

#재귀

개발하는후추 2022. 8. 3. 12:08

재귀 함수

함수가 직접 또는 간접적으로 자신을 호출하는 프로세스를 재귀함수라고 한다

public class PlusFunction {
public static void main(String[] args) {
HelloWorld(5); // HelloWorld 출력 메서드 호출
}

// HelloWorld 출력 메서드 선언
public static void HelloWorld(int n)
{
	// n이 0인 경우 return
	if(n == 0)
		return;
	
	System.out.println("HelloWorld"); // HelloWorld 출력
	HelloWorld(n-1); // 재귀함수 시작
}

}

출처: https://crazykim2.tistory.com/591 [차근차근 개발일기+일상]

'자바' 카테고리의 다른 글

OOP(Object Oriented Programming)  (0) 2022.10.24
재귀함수 #for문  (0) 2022.08.04
#InputStream, OutputStream #Thread(스레드) #Multi-thread(멀티 스레드)  (0) 2022.08.03
#JSON  (0) 2022.08.03
#스트림  (0) 2022.07.27
Comments