aspose file tools*
The moose likes Beginning Java and the fly likes How do  display the contents of List<> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do  display the contents of List<>" Watch "How do  display the contents of List<>" New topic
Author

How do display the contents of List<>

Nimu Chox
Greenhorn

Joined: Mar 11, 2012
Posts: 27
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

Joined: Mar 17, 2011
Posts: 8008
    
  22

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Nimu Chox
Greenhorn

Joined: Mar 11, 2012
Posts: 27
PrintAll() is complaining return type is missing, thanks in advance
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

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

Joined: Nov 09, 2011
Posts: 1030
    
    5

Check the return type defined for findAll() method and then take a look at your implementation of it.
Nimu Chox
Greenhorn

Joined: Mar 11, 2012
Posts: 27
Thanks alot. One more thing, How can I print the "stack trace" of my program?
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: How do display the contents of List<>