Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How to compare two string without using any per-defined method ?

user-image
Question ajoutée par AMITESH KUMAR , SOFTWARE DEVELOPER , TECHZONE TECHNOLOGY PVT. LTD.
Date de publication: 2013/11/02
Ashok Yadav
par Ashok Yadav , trainee , S.O Infotech Pvt. Ltd.

you can first convert that in char array and then compare each character

Amitesh Rai
par Amitesh Rai , SOFTWARE DEVELOPER , techzone technology pvt ltd

already i  have  gone through that  src.zip  and rt.jar ,its ok  but  im  not sutisfied.

Daanish Rumani
par Daanish Rumani , Product Manager , Publicis Sapient

Each String in Java is a CharacterSequence. So you can compare and manipulate two strings the way you want it.

 

However I would recommend you to not do so on your own. The inbuilt methods take care of all the things that you would have never imagined are required to be taken care of (e.g. languages and locales).

 

However if you still want to do it on your own and are asking for code samples then the best place to get "inspired" from is JDK itself! You can check the code of the string methods provided in src.zip shipped as part of the JDK distribution to see how it does its magic.

More Questions Like This