• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Object Array

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I have placed my questions within the code.
 
Ranch Hand
Posts: 157
1
Android MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic