• 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

Displaying rubbish outputs help!

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic