Quantcast
Channel: BTSoru.com - Bilisim ve Yazilim Teknolojileri Soru/Cevap Platformu - latest questions
Viewing all articles
Browse latest Browse all 4270

Recursive metotta işlem sırası

$
0
0
class Test{
    int values[];

    Test(int i){
        values = new int[i];
    }    
    void printArray(int i){
        if(i == 0){
            return;
        }
        else{
            printArray(i-1);
        }

        System.out.println(values[i-1]);

    }
}
class Deneme {
    public static void main(String[] args) throws IOException {
        Test t = new Test(10);

        for(int i = 0; i < 10; i++){
            t.values[i] = i;
        }

        t.printArray(10);

    }
}

printArray metodunda else bloğu nasıl çalışır? Daha doğrusu özyinelemenin olduğu deyimin çalışma mantığı nedir? Bana else bloğundan sonraki `System.out.println(values[i-1]); ifadesinine çalışma sırası else bloğundaki özyineleme tamamen bittikten sonra sadece bir kere gelecek gibi geldi. Mantığı tam oturtturamadım.


Viewing all articles
Browse latest Browse all 4270

Latest Images