Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

constructor problem

 
Greenhorn
Posts: 26
Firefox Browser Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

how to call constuctor from same class method. i am using "this" its generates error then which via constructor call from method in same class...



thanks for all,
sasikumar
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Constructors are not methods and are only invoked during the construction of an object. Why do you want to call one ?
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ssasi kumar wrote:
then which via constructor call from method in same class...



the only way to call the constructor from method is by using *new* key word.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Seetharaman Venkatasamy wrote:the only way to call the constructor from method is by using *new* key word.


Actually there are other ways, like via Reflection (Class.newInstance())
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christophe Verré wrote:Actually there are other ways, like via Reflection (Class.newInstance())


Yes . thanks
 
ssasi kumar
Greenhorn
Posts: 26
Firefox Browser Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
here i attach my snippet code. there is one error occur, that method called fallen in infinite loop. how to avoid infinite loop..





please reply me.....



 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, does this have something to do with your first post or is this a completely different question? If it is a completely new question, then next time please just post it in a new topic instead of appending it to an existing topic as a reply.

Please UseCodeTags when you post source code - I've added them for you in your post above.

The code you posted does not seem to have an infinite loop. You could get an infinite recursive loop if you'd have one method that calls another, that again calls the one, that again calls the other, ... but I don't see that in the two methods you posted.

Also, the code you posted doesn't even compile. Lines 4 and 5 both contain a return statement. The compiler will complain about unreachable code in line 5 when you try to compile this. Please PostRealCode so that we can really see what's happening and what the problem might be.
 
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic