Click here to Skip to main content
15,887,175 members

Comments by @k5hu (Top 8 by date)

@k5hu 15-Sep-18 3:43am View    
yes. But I couldn't get it because its mentioned asList has a generic of type T( the class of object in the array) but why can't it accept ArrayList object alone ?
@k5hu 30-Aug-18 6:48am View    
That's what it returns null
@k5hu 29-Aug-18 7:17am View    
It should return com.mysql.cj.jdbc.Driver instead it returns null
@k5hu 18-Aug-18 1:48am View    
ouptut:
java.lang.StackOverflowError
at oca.GetterSetter.<init>(GetterSetter.java:16)
at oca.GetterSetter.<init>(GetterSetter.java:16)
at oca.GetterSetter.<init>(GetterSetter.java:16)
at oca.GetterSetter.<init>(GetterSetter.java:16)
at oca.GetterSetter.<init>(GetterSetter.java:16)
at oca.GetterSetter.<init>(GetterSetter.java:16)
at oca.GetterSetter.<init>(GetterSetter.java:16)
at oca.GetterSetter.<init>(GetterSetter.java:16)
at oca.GetterSetter.<init>(GetterSetter.java:16)
.
.
.
only line 16 which in here is line 1 is mentioned

but in this :
class Sample {

Sample s = new Sample();//line1
static Sample sa = new Sample();

void check(Sample s) {
System.out.println(this.s == s);
}


}

public class Other
{ Other o=new Other();//line 2
static Other ot=new Other();
public static void main(String[] args) {
new Sample().check(new Sample().s);
}
}
output:
same error in line 2

and in this:
public class Sample {

Sample s = new Sample();//line1
static Sample sa = new Sample();

void check(Sample s) {
System.out.println(this.s == s);
}

public static void main(String[] args) {
new Sample().check(new Sample().s);
}
}

class Other
{ Other o=new Other();//line2
static Other ot=new Other();

}
but here ouput :
same error in line 1

by observing, I found that its happening only with public classes but I can't figure out the exact reason. Could you please help me understand this if possible?
@k5hu 17-Aug-18 14:03pm View    
Sir, but why there is no error in line 3?