• Post Reply Bookmark Topic Watch Topic
  • New Topic

Runtime Error on View Contacts  RSS feed

 
Tim Davis
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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:

 
Knute Snortum
Sheriff
Posts: 4274
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • 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: 4274
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • 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?
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • 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
  • 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: 56525
172
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!