8.582
Bearbeitungen
Jneug (Diskussion | Beiträge) |
Jneug (Diskussion | Beiträge) |
||
| Zeile 443: | Zeile 443: | ||
int position = text.indexOf(","); // 5 | int position = text.indexOf(","); // 5 | ||
text.indexOf("Foo"); // -1 | text.indexOf("Foo"); // -1 | ||
</syntaxhighlight> | |||
|- | |||
| Ersetzt das erste vorkommen von <code>suche</code> mit <code>ersatz</code>. | |||
| {{nowrap|'''String replaceFirst(String suche, String ersatz)'''}} | |||
| <syntaxhighlight lang="java"> | |||
String text = "Hallo, Welt!"; | |||
text.replaceFirst("Welt", "Wald"); // Hallo, Wald! | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |} | ||