class StringExample { public static void main(String args[ ]) { String s1=new String("you are a student"), s2=new String("how are you"); //**********Found**********判断s1与s2是否相同 if (__________________) { System.out.println("s1与s2相同"); } else { System.out.println("s1与s2不相同"); } String s3=new String("22030219851022024"); //**********Found**********判断s3的前缀是否是“220302” if (__________________) { System.out.println("吉林省的身份证"); } String s4=new String("你"), s5=new String("我"); //**********Found**********按字典序,s4大于s5的表达式 if(__________________) { System.out.println("按字典序,s4大于s5"); } else { System.out.println("按字典序,s4小于s5"); } } }
时间: 2023-07-06 07:39:40 浏览: 97
以下是符合要求的代码:
```java
class StringExample {
public static void main(String args[]) {
String s1 = new String("you are a student"), s2 = new String("how are you");
// 判断s1与s2是否相同
if (s1.equals(s2)) {
System.out.println("s1与s2相同");
} else {
System.out.println("s1与s2不相同");
}
String s3 = new String("22030219851022024");
// 判断s3的前缀是否是“220302”
if (s3.startsWith("220302")) {
System.out.println("吉林省的身份证");
}
String s4 = new String("你"), s5 = new String("我");
// 按字典序,s4大于s5的表达式
if (s4.compareTo(s5) > 0) {
System.out.println("按字典序,s4大于s5");
} else {
System.out.println("按字典序,s4小于s5");
}
}
}
```
输出结果为:
```
s1与s2不相同
吉林省的身份证
按字典序,s4小于s5
```
阅读全文