How exactly does a return statement work??
as far as I have learned return statement returns a value from a method unless the method is not void,
now this value depends on type of the method, if the method is of String type it will return a string, if method type is int then returns and integer ..and so on
My doubt is how can a return statement return a method( ) itself ?
if it is doing so can we treat method( ) itself as it's own return type?
recursive method( ) below :
class abc{
String method1(){
System.out.println("Hellworld");
return method1();
}
}
My full code :
package javaapplication6;
class abc{
String method1(){
System.out.println("Hellworld");
return method1();
}
}
public class sample3{
public static void main(String arr[]){
abc obj1=new abc();
obj1.method1();
}
}
