私は文字列変数をいくつか持っており、それらを整数に変換した後にwhile節に入れようとしています。以下while文字列をintに変換した後
実際のコードは:
public void setUp()
{
String HText = "";
int CorrectAnswer = Integer.parseInt(Levels.CorrectAnswer);
int Question1 = Integer.parseInt(Levels.Question1);
int Remaining = CorrectAnswer - Question1;
TextView TVHint = (TextView) findViewById(R.id.hint);
//HintText.setText(String.valueOf(Remaining));
/*while (Remaining != 0)
{*/
if (Remaining >= 100)
{
Remaining = Remaining - 100;
if (HText != "")
{
HText = HText + " + " + "100";
}
else
{
HText = "100";
}
}
else
{
if (Remaining >= 10)
{
Remaining = Remaining - 10;
if (HText != "")
{
HText = HText + " + " + "10";
}
else
{
HText = "10";
}
}
else
{
if (Remaining >= 5)
{
Remaining = Remaining - 5;
if (HText != "")
{
HText = HText + " + " + "5";
}
else
{
HText = "5";
}
}
else
{
if (Remaining >= 1)
{
Remaining--;
if (HText != "")
{
HText = HText + " + " + "1";
}
else
{
HText = "1";
}
}
}
}
}
//}
TVHint.setText(HText);
}
このコードは動作しますが、私は残って0になるまでそれを繰り返したいとしばらくは現在動作しませんコメントアウト。
POSTエラー・コードを助けるください –
***しばらくは失敗する***どうやって?失敗します??? –
Integer.parseInt(var1) – vinod