Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

java.util.StringTokenizer

Empfohlene Antworten

Veröffentlicht

Hi Forum,

der StringTokenizer verhält sich meiner Meinung nach unlogisch. Ich habe folgendes Programm:

  

StringTokenizer st = new StringTokenizer(";;a;b;c", ";");

int i=0;

while(st.hasMoreTokens()) {

   System.out.println(i + ":" +st.nextToken());

   i++;

}

Erwartet hätte ich eine Ausgabe:

0:

1:

2:a

3:b

4:c

stattdessen bekomme ich:

0:a

1:b

2:c

Das ist doch mist!?!?! :confused:

A token is a maximal sequence of consecutive characters that are not delimiters
quelle http://java.sun.com/j2se/1.4.1/docs/api/

ist halt so definiert, dass ein token eine abfolge von zeichen ist.

hth...

String st = new String(";;a;b;c");

String[] s = st.split(";");

Mit split bekommst du auch "leere" Strings.

Gruß Jaraz

hi,

wenn das array auch "leere" elemente am ende enthalten soll, dann mit einem negativen wert als limit.

String s1 = ";;a;b;;c;;";

String[] s2 = s1.split(";", -1);

ansonsten werden die "leeren" strings am ende verworfen.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.