「メソッド」の編集履歴(バックアップ)一覧はこちら
「メソッド」(2011/10/17 (月) 14:09:55) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
***文字列系
**indexOf(String str, int fromIndex)
&bold(){指定されたfromIndex以降でstrが最初に出てくる位置のインデックスを返す}
見つからなかったら-1がかえってくる。
例)
String csv = "aaa,b,cccc,d";
int index = csv.indexOf(",",5);
int indexには6がはいる。
----
**substring(int beginIndex, int endIndex)
&bold(){beginIndexからendIndex -1 までの文字列をとってくる}
例)
String str = "hambuger".substring(4, 8);
strには"urge"が入る
----
**lastIndexOf(String str)
&bold(){指定されたstrが文字列中の一番最後に出てくる位置を返す}
見つからなかったら-1がかえってくる。
例)
String csv = "aaa,b,ccc,d,ccc,f";
int lastIndex = csv.lastIndexOf("ccc");
lastIndex には12が入る。
----
**replaceAll(String regex, String replacement)
&bold(){regexに該当する文字列を、replacementに置換する}
例)
String before = "asami_asami.asami!asami";
String after = replaceAll(".asami", ".chocolate");
afterは"asami_asami.chocolate!asami"になる。
例)J2SE 1.4.xでは
String after = replaceAll("\\Q" + ".asami" + "\\E", ".chocolate");
にしなきゃだめ。
合計:&counter()
***文字列系
**indexOf(String str, int fromIndex)
&bold(){指定されたfromIndex以降でstrが最初に出てくる位置のインデックスを返す}
見つからなかったら-1がかえってくる。
例)
String csv = "aaa,b,cccc,d";
int index = csv.indexOf(",",5);
int indexには6がはいる。
----
**substring(int beginIndex, int endIndex)
&bold(){beginIndexからendIndex -1 までの文字列をとってくる}
例)
String str = "hambuger".substring(4, 8);
strには"urge"が入る
----
**lastIndexOf(String str)
&bold(){指定されたstrが文字列中の一番最後に出てくる位置を返す}
見つからなかったら-1がかえってくる。
例)
String csv = "aaa,b,ccc,d,ccc,f";
int lastIndex = csv.lastIndexOf("ccc");
lastIndex には12が入る。
----
**replaceAll(String regex, String replacement)
&bold(){regexに該当する文字列を、replacementに置換する}
例)
String before = "asami_asami.asami!asami";
String after = replaceAll(".asami", ".chocolate");
afterは"asami_asami.chocolate!asami"になる。
例)J2SE 1.4.xでは
String after = replaceAll("\\Q" + ".asami" + "\\E", ".chocolate");
にしなきゃだめ。
----
**MessageFormat.format(String pattern, Object arguments)
&bold(){指定されたパターンを使って MessageFormat を作成し、それを使用して指定された引数をフォーマットします}
例)
String st1 = "abc{0}";
String st2 = "def";
System.out.println(MessageFormat.format(st1, st2);
結果)
abcdef
合計:&counter()