该程序应该单独调用funFact每个子类,但它只调用该类中的funFact 方法Mammal.我究竟做错了什么?
public class MammalFacts{
public static class Mammal{
public static String funFact(){
return "If you are reading this, there's a 70% chance you're a mammal";
}//end funFact
}//end mammal
public static class Primate extends Mammal{
public static String funFact(){
return "All primates can fly";
}
}//end Primate
public static class Monkey extends Primate{
public static String funFact(){
return "Monkies will rule the earth someday";
}
}
public static void main(String[]args){
Mammal[]i = new Mammal[3]; …Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用数组,但它似乎只是返回原始字符串.
public static String capitalizeEveryOtherWord(String x) {
x = x.toLowerCase();
x.trim();
String[] words = x.split(" ");
for(int c = 2; c < words.length; c += 2)
words[c].toUpperCase();
return Arrays.toString(words);
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?