「Java」contentEquals()メソッドのサンプル

書式
public boolean contentEquals(CharSequence cs)
この文字列と指定されたCharSequenceを比較します。
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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

Java

Posted by arkgame