2012-12-05 149 views

回答

5

您可以使用

str = str.substring(str.indexOf("!")+1); 

希望幫助!

編輯:鏈接到javadoc:substringindexOf

+0

哪部分會被退回? – Mordechai

+0

@ awolfe91,添加到javadoc的鏈接,希望你不介意;) – 2012-12-05 07:01:47

+0

@RC,沒有一點!謝謝! – awolfe91

0
System.out.println(s.substring(s.indexOf("!") + 1)); 
0

你可以做一個String內搜索與

Strings s = "ABD!A"; 
//This gives you the index of the first ! 
int i = s.indexOf('!'); 
//now you can Substring 
String after = s.substring(i+1); 
0
System.out.println(str.substring(s.lastIndexOf("!") + 1)); 

這將打印字符串的部分也就是最後感嘆號之後存在。打印整個字符串,如果沒有「!」有沒有