Closed prakashn27 closed 9 years ago
See this first example in c dude. it is so awesome :) http://stackoverflow.com/questions/198199/how-do-you-reverse-a-string-in-place-in-c-or-c
The issue is that,
if the length of string is 5 then char[0..4] .. so you should send 4 instead of 5 to fix the bug..
See this code.. http://ideone.com/Rvp7aY change your implementation accordingly
no worries dude. i figured it out. return new String(name); this works :+1:
So the lesson is to test the .toString method always and always add it to our custom dataStructures.. because it
Returns a string representation of the object.
In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read.
It is recommended that all subclasses override this method.
http://stackoverflow.com/questions/3615721/how-to-use-the-tostring-method-in-java
I am getting runtime exception while running the code. but it looks correct to me. Check and let me know where i am wrong.