The Artima Developer Community
Sponsored Link

Java Answers Forum
String Util

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

String Util Posted: May 11, 2003 6:22 AM
Reply to this message Reply
Advertisement
Hi Guys,

I saw a recent post on this forum about sorting a String Array in this particular order. Basically whatever starts with A should come before B and so on. However the problem was that small "a" should be also capital "B". Which makes the sequence Aa Bb Cc Dd. The problem is I don't think normal ASCII can be used for this purpose of ordering.

Immediately after seeing the problem I thought I could extend String class and then over ride compareTo method which is in the Comparable interface in order to perform this particular comparison. Also thought of defining a static two dimensional Array with the A = 1, a = 2, B = 3 and b = 4. So based on this array I can write to compareTo method and then call array.sort() method to achieve the required output.

However when I sat to write the code I realized that String class is final and cannot be extended. I need some design advice as to how I can design the class? I can manage the coding.

Senthoor

Topic: Try this one!! I need help. Previous Topic   Next Topic Topic: ejb

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use