🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: be.comp.programming
3 messages
3 total messages Started by Passero Fri, 23 Jan 2004 15:58
[java] strings controleren op alfabetische volgorde
#3184
Author: Passero
Date: Fri, 23 Jan 2004 15:58
4 lines
1363 bytes
Hoe kan ik in java 2 strings controleren op alfabetische volgorde. Dus zo
iets in den aard van: if(string1 > string2) daaruit volgt dat string1 na
string2 komt dus dat string1 bijvoorbeeld peer is en string2 appel. Ik zou
die dus moeten kunnen sorteren. Iemand enig idee?
Re: [java] strings controleren op alfabetische volgorde
#3185
Author: Jeroen Ruijgers
Date: Fri, 23 Jan 2004 16:00
8 lines
1540 bytes
Passero wrote:
> Hoe kan ik in java 2 strings controleren op alfabetische volgorde.
> Dus zo iets in den aard van: if(string1 > string2) daaruit volgt dat
> string1 na string2 komt dus dat string1 bijvoorbeeld peer is en
> string2 appel. Ik zou die dus moeten kunnen sorteren. Iemand enig
> idee?
Kijk even bij het String object:
http://java.sun.com/j2se/1.4.2/docs/api/index.html
Re: [java] strings controleren op alfabetische volgorde
#3186
Author: Matthijs Laan
Date: Fri, 23 Jan 2004 16:11
15 lines
1681 bytes
Passero wrote:

> Hoe kan ik in java 2 strings controleren op alfabetische volgorde. Dus
> zo iets in den aard van: if(string1 > string2) daaruit volgt dat
> string1 na string2 komt dus dat string1 bijvoorbeeld peer is en
> string2 appel. Ik zou die dus moeten kunnen sorteren. Iemand enig
> idee? 
> 

Normaliter kan je String.comareTo() gebruiken. Om locales in de 
vergelijking mee te nemen kan je een Collator gebruiken:

http://java.sun.com/j2se/1.4.2/docs/api/java/text/Collator.html

Matthijs
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads