amit k prabhat

Greenhorn
+ Follow
since Aug 09, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by amit k prabhat

hi shekar,

For further clarification check the following thread
how many string objects will be created
thanks all java_lovers for their respective views n suggestions...
hi all ,
when try to use 'this' with toString(), I got StackOverflowError..
There is no compile time error but at run time I'm getting error.
Is this happens because 'this'(current obj ref) also try to call toString() implicitly and end with StackOveflowError..then what about next line of error message.. java.lang.AbstractStringBuilder.append(Unknown Source)
UnKnown source why??
please discuss this situation..


class Base{
public String toString(){
return ""+this;
}

public Base returnBase(){
return this;
}


}
public class CheckThis{
public static void main(String [] args){
Base b=new Base();
System.out.println(b.returnBase());
// or simply call System.out.println(b); or b.toString();
}
}

/* run time error
Exception in thread "main" java.lang.StackOverflowError
at java.lang.AbstractStringBuilder.append(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at Base.toString(CheckThis.java:3)
*/