System.out.println ("The choice of managers this week" + anyItem + "our recommendation to you");
You did not specify anyItem variable initialized or even declared.
This code: + anyItem +
means getting the value of the toString method of anyItem object
The second thing is why this does not work. You have a System.out.print expression after returning. A program can never reach this line.
You probably want something like:
public Item anyItem() { int index = randomGenerator.nextInt(catalogue.size()); System.out.println("Managers choice this week" + catalogue.get(index) + "our recommendation to you"); return catalogue.get(index);
}
btw: in Java, its condition puts the curly bracket on the same line as the function declaration.
malejpavouk Feb 17 '11 at 20:45 2011-02-17 20:45
source share