Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

newb-array problem

 
Dario Nujic
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I'm working towards my Java 5/6 associate exam and doing practice questions. I came across this problem, I have the way I did and and the way it should be done. Just need to know why the right way is right.
the "shirt class"



What i had to do was create a ShirtArrayTest class and compile both. this is my ShirtArrayTest class



 
Panagiotis Kalogeropoulos
Rancher
Posts: 99
Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not have a closer look again at shirts[1].displayInformtation(); ? Can you see anything strange?
 
Dario Nujic
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DAMN IT!! lol..besides that, should it work the way I had it,minus spelling mistakes, and which way is better and why ?

and thanks for the quick reply and look thru
 
Greg Brannon
Bartender
Posts: 563
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Dario - please keep your line lengths to a reasonable length, 80 columns being about the max. It makes reading the post and replies a lot easier.

Thanks!
 
Panagiotis Kalogeropoulos
Rancher
Posts: 99
Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the quick reply and look thru


No problem!

DAMN IT!!


Dont worry, it happens all the time. Just keep an eye on the results from the compiler. They will guide you on what the problem is and most of the times on the solution too.

If you fix the spelling mistake, it should work without any problems. Regarding your question on which way is better, I would say... it depends! Using the first approach, you write less code, which is good if you don't want to do lots of things with your objects. Using the second approach, you write more code (not always a bad thing, because it improves readability). So, in our case where you simply want to invoke one method, the first approach should be ok. But if you wanted to do more with the objects stored in your table, you should follow the second approach.

Hope the above helped you a little bit.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic