「Java」contentEquals()メソッドのサンプル
書式
public boolean contentEquals(CharSequence cs)
この文字列と指定されたCharSequenceを比較します。
使用例
package com.arkgame.study;
public class ContentEqualDemo {
public static void main(String[] args) {
String url = "/create/";
String[] infoArr = testFunc(url);
for (String str : infoArr) {
System.out.println("結果:" + str);
}
}
public static String[] testFunc(String urlPath) {
String[] res = new String[3];
if ("/create/".contentEquals(urlPath)) {
return new String[] { "A11", "B22", "C33" };
} else {
res[0] = "33";
res[1] = "44";
res[2] = "55";
}
return res;
}
}
package com.arkgame.study;
public class ContentEqualDemo {
public static void main(String[] args) {
String url = "/create/";
String[] infoArr = testFunc(url);
for (String str : infoArr) {
System.out.println("結果:" + str);
}
}
public static String[] testFunc(String urlPath) {
String[] res = new String[3];
if ("/create/".contentEquals(urlPath)) {
return new String[] { "A11", "B22", "C33" };
} else {
res[0] = "33";
res[1] = "44";
res[2] = "55";
}
return res;
}
}
package com.arkgame.study; public class ContentEqualDemo { public static void main(String[] args) { String url = "/create/"; String[] infoArr = testFunc(url); for (String str : infoArr) { System.out.println("結果:" + str); } } public static String[] testFunc(String urlPath) { String[] res = new String[3]; if ("/create/".contentEquals(urlPath)) { return new String[] { "A11", "B22", "C33" }; } else { res[0] = "33"; res[1] = "44"; res[2] = "55"; } return res; } }
結果:A11
結果:B22
結果:C33