• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can anybody explain this code fragment  RSS feed

 
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I am chaitanya, well, I have a small doubt



does this code fragment creates 10 objects, or just it reinitializes the button abject?

If the question is wrong please excuse me.

Thnak you all in advance.
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creates 10 Objects . at the end (btn) reference point to the last object(10th element).,Remaining Objects(1 to 9) are Garbage Collected(Removed from memory)
 
Sheriff
Posts: 21136
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, what do you think it does?
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Chaitanya, Above for loop will create 10 objects but only last object will be assigned to your varaible. Other 9 objects becomes eligible for garbage collector.

-Sunil
 
Rob Spoor
Sheriff
Posts: 21136
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are both right, but could you please ask people try to answer these kinds of questions themselves first? That way they will learn better.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all, for your valuable answers. Well I am working on an application, so I got this doubt, thank you all for shedding light on my question
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anusha chaitanya wrote:Thank you all, for your valuable answers. Well I am working on an application, so I got this doubt, thank you all for shedding light on my question


Anusha,

Did you happened to notice a cool new feature on the ranch...

http://www.coderanch.com/t/475579/Ranch-Office/Marking-thread-as-resolved


No... need to edit the title with "[SOLVED]" anymore...

Henry
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Henry thanks for helping me.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!