• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Runtime Error on View Contacts

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my code, can someone explain why get a runtime error when choosing option 2 after adding a contact?

Main:




Business Contact:




Personal Contact:


Contact:

 
Sheriff
Posts: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Tim.

Thanks for formatting your code. Please also UseCodeTags (← click), that will help a lot. I did it for you this time.
 
Knute Snortum
Sheriff
Posts: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

can someone explain why get a runtime error when choosing option 2 after adding a contact?



Aren't you throwing the error?
 
Marshal
Posts: 80655
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. Sorry. With several hundred lines of code, we cannot. Please supply more details and then we can have a go.

Please don't use different text sizes and colours for code, use code tags. I have changed your post, and doesn't it look better I also had to break the long lines, and you can see how it should be done.
I can see some other problems. Your loop in line 139 should read something like this:-… And your Contact class should override the toString method.
You have an empty catch in line 131, which is dangerous. Does the method that is inside actually compile? Does it give errors about IOException is never thrown?
I don't like while (true)...

Sorry for giving you all that bad news, but we shall try to help you sort it all out.

And welcome to the Ranch
 
Tim Davis
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have updated my code as follows and I am getting there but still throwing an error on view contacts. I am getting the following error:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>
at contactlist.ContactList.viewContacts(ContactList.java:139)
at contactlist.ContactList.main(ContactList.java:48)


Any further help would be greatly appreciated.

Here is my main:



Here is my Contact:



Here is my Personal Contact:



Here is Business Contact:

 
Campbell Ritchie
Marshal
Posts: 80655
477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are not getting a runtime error at all. You are forcing your IDE to try and execute uncompiled code. Don't. If you want help you will have to tell us the error messages from the IDE's compiler.
 
reply
    Bookmark Topic Watch Topic
  • New Topic