方法:
public String getRowsOf3Stars (int rows)
説明:
必須課題 2) パラメータとして int(rows) が渡される getRowsOf3Stars メソッドを完了します。このメソッドは、その数の 3 つ星行を含む文字列を返します。
例えば、
getRowsOf3Stars(2) // returns “***\n***\n”
行が 1 未満の場合、空の文字列を返します。例:
getRowsOf3Stars(2) // should return "***\n***\n"
私が書いたもの:
public String getRowsOf3Stars (int rows) {
String getRowsOf3Stars="***\n";
if (rows<1){
String none="";
return none;
}
else{
for(int starRows=1;starRows<rows;starRows++){
return getRowsOf3Stars;
}
}
}
CodeWrite で受け取るエラー:
private String getRowsOf3Stars(int rows) throws Exception {
>> This method must return a result of type String
私のプログラムが文字列を返さない理由を誰か説明してもらえますか?