• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

why StackOverowError ??

 
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why there is StackOverowError ??





naveen
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have recursive initialization calls- One in main which triggers a new instance creation and then in the class definition you have: CCL test = new CCL(); which leads to a instance creation call and this continues.
So you should be removing: CCL test = new CCL(); from your class definition
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i didn't understand that. can you you elaborate ?

what i think is here how it flows :

when control on line 11-->
object instantiation say ob@1 starts here
line 3 executes object instantiation say ob@2 starts here
obj@2 proceeds to execute line 5 to 7.
obj@2 completes.
obj@1 initialize test var on line 3
obj@1 run constructor
obj@1 completes


where is recursion ??



naveen
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

naveen yadav wrote:i didn't understand that. can you you elaborate.

what i think is here how it flows :

when control on line 11-->
object instantiation say ob@1 starts here
line 3 executes object instantiation say ob@2 starts here
obj@2 proceeds to execute line 5 to 7.
obj@2 completes.
obj@1 completes.


where is recursion ??


Line 11 executes an object instantiation - this triggers line 3 to execute.
Line 3 again initiates an object instantiation - this triggers line 3 to execute. and this repeats.
The reason is that line 3 is executed everytime a new instance is created. So you see the recursion there.
 
Ranch Hand
Posts: 47
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

naveen yadav wrote:i didn't understand that. can you you elaborate ?

where is recursion ??




Every call new Cert() creates an instance of Cert. One of Cert field is initiated as new Cert(), which causes creation of Cert object containing Cert field, which has to be instantiated as new Cert(), which again causes creation of new Cert() object, which has to have initialized all fields, especially this field which is created as new Cert(), which causes .... this is recursion ;)
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys . i got it now.
 
Ranch Hand
Posts: 87
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if the issue is resolved then click on the "Resolved" button.
 
"To do good, you actually have to do something." -- Yvon Chouinard
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic