• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

How do display the contents of List<>

 
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.


 
Bartender
Posts: 10777
71
Hibernate Eclipse IDE 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
Posts: 10777
71
Hibernate Eclipse IDE 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
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • 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
Posts: 10777
71
Hibernate Eclipse IDE 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
 
I child proofed my house but they still get in. Distract them with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!