• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parameters  RSS feed

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've been gien a method with signiture:


There are two classes: Order and Item. An order can have many items. The addItem method simply adds a new Item from the Item class into an arraylist in the Order class.

I just don't know what the parameter of this method means (anItem : Item). Does it have something to do with enhanced for loops (which can be used for adding a new item to the arraylist)?

Thanks in advance
[ May 19, 2008: Message edited by: Alireza Bahmanpour ]
 
author & internet detective
Marshal
Posts: 37518
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alireza,
That does not compile in Java. Maybe it was pseudo code?

The correct signature in Java is:
public void addItem(Item anItem)
 
Alireza Bahmanpour
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm...I'm not sure, because it was given in a UML diagram. So it should be a mistake!

Thanks for the help
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure, because it was given in a UML diagram. So it should be a mistake!


UML diagrams are not specific to Java. Or any language. So you will need to translate the design into a code skeleton (and then, of course, implement the code).

Henry
 
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "anItem : Item" syntax is also used by Delphi, and usually means: the parameter is called anItem, and its type is Item. In Java this would translate to "Item anItem".
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that UML takes its syntax from languages like Pascal where "anItem: Item" is the usual way to write a method parameter.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!