文字列定義
String s1 = new String();
System.out.println(s1);
char[] arrayList = {'a', 'b', 'c'};
String s2 = new String(arrayList);
System.out.println(s2);
byte[] byteList = {97, 98, 99};
String s3 = new String(byteList);
System.out.println(s3);
String str = "Welcome to China!";
String str2 = "welcome to China!";
文字列の比較
System.out.println(str == "Welcome to China!");
System.out.println(str.equals(str2));
System.out.println(str.equalsIgnoreCase(str2));
文字列長取得
System.out.println(str.length());
文字列接合
System.out.println(str.concat(str2));
System.out.println(str + str2);
文字列指定位置の内容
System.out.println(str.charAt(0));
文字列の中のある文字が初めて現れる位置
System.out.println(str.indexOf("lco"));
文字列切り取り
System.out.println(str.substring(8));
System.out.println(str.substring(0, 8));
文字列カット
String[] newList = str.split(" ");
System.out.println(Arrays.toString(newList));
文字列変換
char[] arrayList1 = str.toCharArray();
System.out.println(arrayList1);
byte[] byteList1 = str.getBytes();
System.out.println(Arrays.toString(byteList1));
文字列置換
String newStr = str.replace("!", "?");
System.out.println(newStr);