+ 5

Methods from Methods

In Python you can make a function that can call other functions, can you do the same thing woth methods in Java.

4th Aug 2017, 3:40 PM
Caden Schindler
Caden Schindler - avatar
8 Respostas
+ 13
Yes but you can do anything.... This is just an example....
4th Aug 2017, 7:11 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 20
public int method2() { return 1; } public int method1() { return method2(); }
4th Aug 2017, 7:08 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 14
Yes.
4th Aug 2017, 3:42 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 1
ValentinHacker what is the syntax for it in Java please
4th Aug 2017, 6:03 PM
Caden Schindler
Caden Schindler - avatar
+ 1
so does that just use the return type of the other method
4th Aug 2017, 7:10 PM
Caden Schindler
Caden Schindler - avatar
- 1
Absolutely, and it can also call itself: public void print_n_times(n): System.out.println("hi") print_n_times(n - 1)
26th Oct 2021, 1:11 PM
Sam ツ
- 2
Can't answer
4th Sep 2020, 3:08 AM
Abdulai
Abdulai - avatar