Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
It's invoking the base class toString(). Without it, it would invoke the current (or lowermost-in-the-hierarchy) toString, and you run the risk of getting into an infinite recursive loop. I am surprised that didn't happen to you already.
Originally posted by Stuart Ash: It's invoking the base class toString(). Without it, it would invoke the current (or lowermost-in-the-hierarchy) toString, and you run the risk of getting into an infinite recursive loop. I am surprised that didn't happen to you already.
Given that it works I think he meant the call super.toString(), not just wacking super from it. I could be wrong on that assumption
If he whacked the "super" in "super.toString()", the program would still run just fine, because (on cursory examination, I could have missed something) SmallBall.toString() is never called. If that method were ever called, then there would indeed be a problem. But as is, he could also have just erased the whole toString() method and again changed nothing.
[Stuart]: Ah heck!! He meant super() and not super.toString(). We got misled.
What? He clearly said super(). Who misled you?
Adding to Jesper's answer, I would note that although calling super() is unnecessary (since it's done impliticly anyway), some people like to always make this call explicitly. It can be useful for reminding newbies that the super constructor is getting called. Although the down side is it may confuse newbies, as they may think that if the super() isn't there, it isn't called. Anyway, some people think requiring an explicit super() is good idea, and some IDEs such as IntelliJ can be configured to either (a) warn you if you fail to call super(), or (b) warn you if you do call super() when it's not necessary. Whichever you prefer...
While the call is unnecessary, declaring it useless is a matter of opinion not fact. I prefer to make the call explicitly for consistency and readability. Plus, if someone is so new they don't understand this is otherwise implicit hopefully it will force them to find out. I'll take that over them continuing on oblivious to what's happening for them. Besides, within reason the more clearly code expresses what it's doing and the less it leaves to be implied the better.
I wouldn't object to other's leaving it implicit, but it's not my preference.
Originally posted by madhav changala: Thanks to all .But only few people got right track , i donot y someone misled by super().to String any how i am thankful to u r advice expecially to Jim Yingst . ok
In the future, you should only post the code relevant to your question. I think that the large amount of code you posted here lead to the confusion. In this case, you could have simply posted the constructor, and perhaps the enclosing class as well.