问答题 本程序比较两个字符串"Welcome to China!"和"Welcome you back home!"的大小(即对应字符相比较,出现第一个不相等的字符时,大的所在的字符串大,小的所在的字符串小,字符的比较相当于字符对应的ASCII的比较)。 public class exam_43{ public static void main(String[] args){ String str1="Welcome to China!"; String str2="Welcome you back home!"; int l=str1.length()<str2.length()?______; char c1='', c2=''; for(int i=0; i<1; i++){ c1=str1.charAt(i); c2=str2.charAt(i); if(______) ______; } if(c1>c2) System.out.println("""+str1+"""+">"+"""+str2+"""); else System.out.println("""+str1+"""+"<"+"""+str2+"""); } }
【正确答案】str1.length():str2.length() c1!=c2 break
【答案解析】