This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying rubbish outputs help!

 
Jamie Cotton
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jamie Cotton
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic