【发布时间】:2016-02-07 20:51:52
【问题描述】:
我正在尝试制作一个使用 while 循环反转字符串的应用程序。只是想知道我是否走在正确的道路上。
所以我想我会做一个while循环来确定我应该做多少chars。然后我会在控制台中反向打印它们。
到目前为止,这是我的代码。任何帮助将不胜感激。
// Get the text from the input from the user
// Outputs it to the Text area
// Uses while loop to calculate how many chars to create
String Startword = txfInput.getText();
int LengthOfWord = Startword.length();
int Counter = 1;
while (Counter <= LengthOfWord)
{
// Creates amounts of chars based off the counter
Counter = Counter +1 ;
}
有什么建议吗?
【问题讨论】:
-
@Satya 问题指定了一个while循环。所以你不能指出任何问题,因为它有 33 个答案,我想我在第一页上没有看到任何带有 while 循环的答案。如果您看到任何使用 while 循环的答案,请分享它的链接。
标签: java