• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Runtime Error on View Contacts

 
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:

 
Sheriff
Posts: 6175
163
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • 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: 6175
163
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • 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?
 
Marshal
Posts: 65423
248
  • 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: 65423
248
  • 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.
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!