public class B{ public static void main(String args[]) { System.out.println(compareTwoDigit("welcome","to")); Thread a = new Thread(new A()); a.start();
} public static int compareTwoDigit(String a,String b){ return a.length() >= b.length()?a.length():b.length();
} public void output(){ System.out.println("output()"); } } class A extends B implements Runnable { A() { Thread thread = new Thread(); } public void run() { while(true) { this.output(); try { Thread.sleep(3000); }catch (Exception e){ } } } }
public static void main(String args[]) {
System.out.println(compareTwoDigit("welcome","to"));
Thread a = new Thread(new A());
a.start();
}
public static int compareTwoDigit(String a,String b){
return a.length() >= b.length()?a.length():b.length();
}
public void output(){
System.out.println("output()");
}
}
class A extends B implements Runnable {
A() {
Thread thread = new Thread();
}
public void run() {
while(true) {
this.output();
try {
Thread.sleep(3000);
}catch (Exception e){
}
}
}
}
Thread thread = new Thread();
}
===================================================
这里应该是
A() {
Thread thread = new Thread(this);
}
吧====================================
====================================
而且比较字符串不仅仅是比较字符串的长度的。是按照码值来比较的。而且题目要求返回较大字符串的大写。public String compareTwoDigit(String a,String b){
return a.compareTo(b) >= 0 ? a.toUpperCase() : b.toUpperCase();
}