Ich habe folgendes Programm hier und ich verstehe es nicht könntet ihr mir bitte das sehr detailiert erklären?
Alles anzeigen
Danke schonmal für die hilfe (hoffentlich)
Quellcode
- public class P {
- private Long method1(Long x, Long y) {
- if (y == 1)
- return x;
- return x + method1(x, y-1);
- }
- private Long method2(Long x, Long y, Long z) {
- z = y - 1;
- if (y==1)
- return x;
- return method1(x, method2(x,y-1,z));
- }
- public static void main (String [] args ) {
- P p = new P();
- Long a = new Long (2),
- b = new Long (5),
- c = new Long (a-b);
- System.out.print("Result: " +p.method2(a,b,c));
- }
- }
Danke schonmal für die hilfe (hoffentlich)