Two Laptop Bag*
The moose likes Beginning Java and the fly likes using compareTo() in string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using compareTo() in string" Watch "using compareTo() in string" New topic
Author

using compareTo() in string

Pratik D mehta
Ranch Hand

Joined: Jul 29, 2010
Posts: 121


I am getting answer as
sat
rat
are
zap
xem
But it is expected that we should get this
are
rat
sat
xem
zap
This question is very simple but , I dont get the flaw .


Understanding is Everything - Peter Lord
Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 150

Try removing the ; from line 9. And see what happens

Gary


star chaser..
Pratik D mehta
Ranch Hand

Joined: Jul 29, 2010
Posts: 121

Thank you gary .
I invested about 2 hours on this simple thing .
Its was so silly of me.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Is your source code really formatted like that?
Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 150

Thank you gary .
I invested about 2 hours on this simple thing .
Its was so silly of me.


We've all been there. Sometimes we stare at code for too long that we miss the actual problem. A second eye would not hurt either.
Glad I softened the head banging.

Gary
 
Don't get me started about those stupid light bulbs.
 
subject: using compareTo() in string
 
Similar Threads
Sort the Array in reverse order
Bubble Sorting - String Literal
What is the input file?
arrays?
Ignoring of blanks