Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do display the contents of List<>

 
Nimu Chox
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to this
I created the method that is intended to display all the contents in an array:

public List<Customer> findAll() {

for (Customer customerElement : CustomerList)
{
System.out.println( customerElement );
}

}

"Error : Missing statement"


I have tried to change to the following:
public customer findAll() {

for (Customer customerElement : CustomerList)
{
System.out.println( customerElement );
}

}
but still the same error, please help.


 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nimu Chox wrote:I created the method that is intended to display all the contents in an array:
...
"Error : Missing statement"...

I suspect you're getting a lot more information than just that. Please provide the entire stack trace exactly as it was produced.

Also, please UseCodeTags (←click).

Winston
 
Nimu Chox
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PrintAll() is complaining return type is missing, thanks in advance
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nimu Chox wrote: PrintAll() is complaining return type is missing, thanks in advance

Actually, I think you mean findAll(), and I suspect that it's complaining that you're NOT returning anything, not that the return type is missing.

As I said before, please post the exact message you are getting (all of it).

And also: fields and methods should start with a lowercase letter. It's not a language requirement, but it is an established convention, so you should stick to it.

Winston
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the return type defined for findAll() method and then take a look at your implementation of it.
 
Nimu Chox
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot. One more thing, How can I print the "stack trace" of my program?
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nimu Chox wrote:Thanks alot. One more thing, How can I print the "stack trace" of my program?

Well, usually you do it when you get an Exception, in which case it's {name-of-Exception}.printStackTrace(), but you can also print it out for the current Thread via Thread.currentThread().

However, if you got an error when you compiled, the message you already posted will have been part of a larger stack trace that includes method names and line numbers. Just copy and paste that.

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic