File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Displaying rubbish outputs help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Displaying rubbish outputs help!" Watch "Displaying rubbish outputs help!" New topic
Author

Displaying rubbish outputs help!

Jamie Cotton
Greenhorn

Joined: Nov 12, 2004
Posts: 16
Hiya all

I am trying 2 to build a EVERY basic email organiser I have 2 class's and 1 program but everytime I compile and run the program I get


What does that mean?

Here is a link to my files Java Filesand would be very happy if someone could look at them and tell me where i cam going wrong

Thanx in advance
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi Jamie,

Welcome to JavaRanch!

If you use System.out.println() to print an Inbox object, like this:

Inbox box = new Inbox();
System.out.println(box);

then println calls (indirectly) the method Inbox.toString() and displays the String that the method returns. Every class inherits a version of toString() from java.lang.Object which returns the class name, followed by the '@' character, followed by the result of calling the hashCode() method. If your class doesn't have a toString() method, then this inherited version is called.

So to fix this, you might give Inbox a method like



which, if Inbox has a member variable "name" that holds the user's name and one named "count" that holds the number of messages, will print something like

Jamie's Inbox: 3 message(s).

instead.


[Jess in Action][AskingGoodQuestions]
Jamie Cotton
Greenhorn

Joined: Nov 12, 2004
Posts: 16
Hiya

Ok i took your advice but cant seem 2 get my head around it


but i get the error message

"array required, but java.util.ArrayList found"

Help agen plz
Mark Patrick
Ranch Hand

Joined: Feb 22, 2004
Posts: 51
Is MessageList an array or an ArrayList? Your 'for' construct called the size() method of an ArrayList, but in the body you are calling the elements of an array using MessageList[i]. Which is it?

If MessageList is an array, then change your 'for' construct to use MessageList.length instead of MessageList.size(). (**Note there are no "()" after length as it is a property of an array and not a method).
My guess is that your problem is here.

If MessageList is an ArrayList, then change the way you call elements from MessageList[i] to MessageList.get(i).


Mark Patrick<br />SCJP 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying rubbish outputs help!