導入Java . util . scanner;
公共D類
公共靜態void main(String[] args) {
Scanner sc =新掃描儀(system . in);
System.out.println("請輸入第壹個字符串:");
string s 1 = sc . next line();
System.out.println("請輸入第二個字符串:");
string S2 = sc . next line();
if(s1.length()>s2.length()){
system . out . println(s 1);
} else if(s 1 . length()& lt;s2.length()){
system . out . println(S2);
}否則{
if(s1.charAt(0)>s2.charAt(0)){
system . out . println(s 1);
} else if(s 1 . charat(0)& lt;s2.charAt(0)){
system . out . println(S2);
}否則
system . out . println(s 1);
}
}
}