1

这是我的代码的一小段。它工作得很好,但是如果我想为每个字符串变量 str 添加一个数字怎么办。我该怎么做?请帮忙。Collections.shuffle(arrlist);

for(int i=0;i<nb;i++){
    String str = (String) arrlist.get(i);
     //worker.parseXHtml(writer, document, new StringReader("<br>")); 
     worker.parseXHtml(writer, document, new StringReader(str));   
}

4

1 回答 1

1

尝试

String str = (String) arrlist.get(i)+String.valueOf(someNumber);

如果你想添加i

String str = (String) arrlist.get(i)+String.valueOf(i);

更新

public static void main(String[] args) {
        List arrlist = new ArrayList<>();
        arrlist.add("tester");
        int i = 0;
        String str = (String) arrlist.get(i) + String.valueOf(i);
        System.out.println(str);

    }

o/p:

tester0
于 2013-09-28T07:45:19.803 回答