开发者

Easiest way to add a numeric value to a String name

I have a string name called "name" that I am looking to convert to name1, name2, name3, name4

what would be the best way to go about doing this? Is there a way to tie it into a loop?

public String name;

Loop Start

public void onClick(DialogInterface dialog, int whichButton) {
      n开发者_StackOverflow社区ame = input.getText().toString();
      // Do something with value!
}

Loop End

Looking for each time it goes through the loop to become name1, name2, name3, name4..

is it possible to do something like

name(nameLoop) = input.getText().toString();
...
nameLoop++;

I hope this isnt too confusing.

Thanks in advance!


Sure, write something like String newName = name+nameLoop;

or String newName = "name"+nameLoop; if you literally want them to be name1, name2 etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜