This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Overiding Java toString method  RSS feed

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i print overide the toString for WebBrowser as i would like to print out the object bc. Tested the program and it is fine if i put it in the main method rather than the WebBrowser constructor.

 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean. You can just add a toString() method to your class WebBrowser.

What do you mean with "it is fine if i put it in the main method rather than the WebBrowser constructor" - if you put what exactly in the main method rather than the WebBrowser constructor?
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

benjamin parker wrote:How do i print overide the toString for WebBrowser as i would like to print out the object bc.


Like Jesper, I'm completely mystified as to what your problem is, so back up and TellTheDetails (←click).

You're also not helping yourself by using cryptic names like 'bc'. It may mean something to you, but it certainly doesn't to us.

All I see so far is a class called WebBrowser that takes lines from a Scanner, encoded according to rules that you haven't explained to us, that loads a linked list that you've rolled yourself.

My advice: Deal with one thing at a time.

If you want to write a Lynx-like web browser - which is a formidable enough task just by itself - don't compound it by re-inventing the wheel. Java already has a perfectly good linked list class (called, strangely enough, LinkedList; which might also cause you problems unless you're very careful), which has been thoroughly tried and tested, so you don't need to.

HIH

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!