Java将double转换为字符串

时间:2014-06-06 22:52:51

标签: string awt double jlabel

您好我正在尝试将这两个双变量转换为String,以便它可以显示在JLabel AnswerLabel

double GasType;
double CostOfGas;

Answer = GasType * CostOfGas;
this.AnswerLabel.setText(Answer);

1 个答案:

答案 0 :(得分:0)

这将有效:

this.AnswerLabel.setText("" + Answer);

但这更好:

this.AnswerLabel.setText(String.valueOf(Answer));