Sunday, August 14, 2011

How to get Object parameters in Java?

Alright, a couple of things. Instead of making a LinkedList, you should make a LinkedList. Either that, or create a toString() method in the Deal cl, (because then you could keep it as an Object and run its toString() method). Secondly, the code won't work right because your value and name for the Deal cl are static, meaning they are shared between each instance of the Deal cl. This means that every time you call new Deal(x, y), it is changing the name and value values for EVERY instance of the Deal cl. If the last Deal cl you make is Deal (4, "Four"), then the value and name for EVERY Deal instance is going to be 4 and "Four".

No comments:

Post a Comment