• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do display the contents of List<>

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PrintAll() is complaining return type is missing, thanks in advance
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot. One more thing, How can I print the "stack trace" of my program?
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic