-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringEqual.java
More file actions
38 lines (32 loc) · 1004 Bytes
/
Copy pathStringEqual.java
File metadata and controls
38 lines (32 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.example;
public class StringEqual {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String strOne="Hello";
String strTwo="hello";
String strThree="Hello";
if (strOne.equals(strThree))
{
System.out.println("strOne and strThree are equal");
}
if (strOne==strThree)//判断java字符串值相等 不能用==
{
System.out.println("strOne and strThree are not equal");
}
if (strOne.equalsIgnoreCase(strTwo))//忽略大小写
{
System.out.println("strOne and strTwo equal");
}
System.out.println(strOne.compareTo(strTwo));//按照字典顺序,在strTwo前返回负数
if(strOne.startsWith("H"))
{
System.out.println("startsWith H");
}
String aa= strOne.replace("He", "哈哈");
System.out.println(aa);//返回新字符串
System.out.println(strOne);
}
}