Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Quick question about JavaBeans

 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was the closest forum I could find to post this question. Mods, if you don't agree, please move it where you think it belongs. Thanks!

I am taking an IBM online course and it states: "An indexed property represents a range of values that the property may hold. This range of values is held in an array."

This is in reference to JavaBeans which are picky about small details so I was wondering... Do ranges of values HAVE to be stored in an array to have a properly formed JavaBean? Can't you use one of the collection APIs?

Thank you!
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the material in the online course explicilty state that "in order to have a properly formed JavaBean, a range of values must be stored in an array?"
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does not say that explicitly, but it also does not say you can use another form of collection. From the above quote, "This range of values is held in an array." <-- It doesn't say "array or some other collection type" so I want to make sure about this.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is more a question about the Java Bean specification than about design in general - moving to Java in General.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are adding too much "hypothesis" to the statement. The indice structure of an Java-based array does not apply to the Collection class, it's implementation classes, or the objects stored in a collection. However, this is not directly related to the JavaBean format.

There is a "context" missing from your first post. You did not explain clearly how the sentence you quoted relates to correctly implementing a JavaBean according to the specification. The sentence is simply conveying the indice structure of an array and explaining what an indexed property means. There is no mention of Java Collections in the sentence.

You can store a "range of values" in a Collection, in the form of objects. However, this is not indexed the way a Java-based array is. Maybe at a deep, implementation level, but not something the application programmer programs with in the API.

Below is a example of a valid JavaBean.


[ December 15, 2008: Message edited by: James Clark ]
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply James... that answers my question!

ps: Looks like I graduated... my stuff is now getting moved to intermediate section instead of beginners section
[ December 15, 2008: Message edited by: Brian Legg ]
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good luck on your test!
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heh, I meant on the forums James

I'm not in school, so no tests for me!
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you are preparing for the SCJP6 test, currently. If so, good luck on the test
[ December 15, 2008: Message edited by: James Clark ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic