私のコードが原因で PrintStream が新しい行に移動する理由がわかりません。
// displays the total time of the leak in months from the calculateLeakTime() method.
String leakTime = LeakCalculator.calculateLeakTime();
System.out.println("The total time of the leak is " + leakTime + " months.");
出力は次のようになります。
「リークの合計時間は12
か月です。」
月が新しい行に印刷されている理由がわかりません。私もこれを試しました:
// displays the total time of the leak in months from the calculateLeakTime() method.
String leakTime = LeakCalculator.calculateLeakTime();
System.out.print("The total time of the leak is " + leakTime);
System.out.println(" months.");
そして、私は同じ出力を得ました。「月」を新しい行に移動する理由を誰かが説明できますか?
ありがとう、
ケビン
編集:これがcalculatLeakTime()メソッドです:
static String calculateLeakTime() throws ParseException{
long leakEndMili = getLeakEnd();
long leakBeginMili = getLeakBegin();
long timeDays = ((leakEndMili - leakBeginMili) / (1000 * 60 * 60 * 24));
double timeMonths = (double) (timeDays * 0.0328549);
System.out.println(timeMonths);
String monthsRounded = String.format("%.0f%n", timeMonths);
return monthsRounded;
}