標題:
equals() 函式
[打印本頁]
作者:
tonyh
時間:
2012-11-3 17:02
標題:
equals() 函式
本帖最後由 tonyh 於 2012-11-14 20:38 編輯
equals() 函式可對兩組字串做比對, 若比對結果為一致系統回傳true, 不一致則回傳false.
public class ch40
{
public static void main(String args[])
{
String a="星星", b="月亮", c="太陽", d="星星";
System.out.println(a.equals(a)); //true
System.out.println(a.equals(b)); //false
System.out.println(a.equals(c)); //false
System.out.println(a.equals(d)); //true
System.out.println(c.equals(b)); //false
}
}
複製代碼
作者:
t2364705
時間:
2012-11-3 17:04
public class ch40
{
public static void main(String args[])
{
String a="星星", b="月亮",c="太陽",d="星星";
System.out.println(a.equals(a));
System.out.println(a.equals(b));
System.out.println(a.equals(c));
System.out.println(a.equals(d));
System.out.println(b.equals(b));
}
}
複製代碼
作者:
t3742238
時間:
2012-11-3 17:04
public class ch40
{
public static void main(String args[])
{
String a="星星",b="月亮",c="太陽",d="星星";
System.out.println(a.equals(a));
System.out.println(a.equals(b));
System.out.println(a.equals(c));
System.out.println(a.equals(d));
System.out.println(c.equals(a));
}
}
複製代碼
作者:
劉漢文
時間:
2012-11-3 17:06
public class ch40
{
public static void main(String args[])
{
String a="星星", b="月亮",c="太陽",d="星星";
System.out.println(a.equals(a));
System.out.println(a.equals(b));
System.out.println(a.equals(c));
System.out.println(a.equals(d));
System.out.println(b.equals(b));
}
}
複製代碼
作者:
黃博鴻
時間:
2012-11-3 17:07
public class ch40
{
public static void main(String args[])
{
String a="星星", b="月亮", c="太陽", d="星星";
System.out.println(a.equals(a));
System.out.println(a.equals(b));
System.out.println(a.equals(c));
System.out.println(a.equals(d));
System.out.println(c.equals(b));
}
}
複製代碼
作者:
尤泓鈞
時間:
2012-11-3 17:08
public class ch40
{
public static void main(String args[])
{
String a="星星",b="月亮",c="太陽",d="星星";
System.out.println(a.equals(a));
System.out.println(a.equals(b));
System.out.println(a.equals(c));
System.out.println(a.equals(d));
System.out.println(c.equals(b));
}
}
複製代碼
作者:
粘靖瑜
時間:
2012-11-3 17:09
public class ch40
{
public static void main(String args[])
{
String a="星星", b="月亮", c="太陽", d="星星";
System.out.println(a.equals(a)); //true
System.out.println(a.equals(b)); //false
System.out.println(a.equals(c)); //false
System.out.println(a.equals(d)); //true
System.out.println(c.equals(b)); //false
}
}
複製代碼
作者:
粘靖瑜
時間:
2012-11-3 17:10
public class ch40
{
public static void main(String args[])
{
String a="星星", b="月亮", c="太陽", d="星星";
System.out.println(a.equals(a)); //true
System.out.println(a.equals(b)); //false
System.out.println(a.equals(c)); //false
System.out.println(a.equals(d)); //true
System.out.println(c.equals(b)); //false
}
}
複製代碼
作者:
蔡昀佑
時間:
2012-11-10 16:58
public class ch40
{
public static void main(String args[])
{
String a="星星", b="月亮", c="太陽", d="星星";
System.out.println(a.equals(a)); //true
System.out.println(a.equals(b)); //false
System.out.println(a.equals(c)); //false
System.out.println(a.equals(d)); //true
System.out.println(c.equals(b)); //false
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2