This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object Array

 
Vishnu Khera
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I have placed my questions within the code.
 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishnu, you need to check your beans
I am providing you code snippet here for help


Hope this will help.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishnu Khera wrote:


You don't need check[whatever] there. You already have the current element in the obj variable.

This:

is equivalent to this:
 
Red Smith
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishnu Khera wrote:

That version of the for statement would not use check with an index, e.g.: check[i] the way this version does:


The version you are using puts each check element into obj as it loops. So you access obj each time, not check with a subscript.

Vishnu Khera wrote:


obj.getClass().getCanonicalName() will give the type that you can do a String compare on or use instanceof with.


 
Vishnu Khera
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff and Red, you are awesome Thank you so much

Oops.. this was a very easy one got carried away with all these concepts of arrays, reference type - type conversions

getCanonicalName() was really helpful
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic