解题思路:
注意事项:
参考代码:import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
import javax.print.attribute.HashAttributeSet;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s1 = sc.next();
String s2 = sc.next();
//compareTo() 方法用于两种方式的比较:
//字符串与对象进行比较。
//按字典顺序比较两个字符串。
//int sum = s1.compareTo(s2);
//System.out.println(sum);
int sum=0;
int len1 = s1.length();int len2 = s2.length();
if(s1.equals(s2)){
System.out.println(0);
return;
}
else if(len1
sum = len1-len2;
for (int i = 0; i
if (s1.charAt(i) != s2.charAt(i)) {
sum = s1.charAt(i) - s2.charAt(i);
break;
}
}
}
else {
sum = len1-len2;
for (int i = 0; i
if (s1.charAt(i) != s2.charAt(i)) {
sum = s1.charAt(i) - s2.charAt(i);
break;
}
}
}
System.out.println(sum);
}
}