• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Objects instance variables value

 
Akshay Reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


what is the difference between line 2 and line 3,
how does the values of e1.count and e2.count read for line 2 and line3
(say)
 
Henry Wong
author
Marshal
Pie
Posts: 21415
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between line 2 and line 3,


In line 2, you are declaring a reference, and initializing it to the same object that is referenced by another reference.

In line 3, you are declaring a reference, and initializing it to a new object.

Henry
 
Akshay Reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you mean in line 2 e1 and e2 refer to the same object and in line 3 e2 is refering to a different object ...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.

Your while loop body will never execute, btw.
 
Akshay Reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am sorry x<4 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic