「Java勉強」replaceAll()、StringBuffer()とsplit()のまとめ

例1 指定の文字列に置換replaceAll()
String s = “1 3 2 4 welcome to startnews24 .com";
s = s.replaceAll(“\\s+", “\t");
System.out.println(s);

例2 StringBufferについて
StringBuffer()
StringBuffer(int capacity)
StringBuffer(String string)
StringBuffer(CharSequence cs)

例3 文字列を分割(split)
String str_time="18:00-19:00″;
String time[] = str_time.split(" “);
if(time.length==1){
time = str_time.split(“-“);
}
System.out.println(time[0]);
System.out.println(time[1]);

Java

Posted by arkgame