Converting an int to String(Java)

后端 未结 2 785
太阳男子
太阳男子 2021-01-23 15:43

Let\'s say I run on a for with i from 0 to 6, each run in the for I initialize a class that gets as a parameter a name, ex:

ClassThing[] a = new ClassThing[6];
f         


        
相关标签:
2条回答
  • 2021-01-23 16:32

    as said before, you can either use

    a[i].name = Integer.toString(i);
    

    or

    a[i].name = ""+i;
    

    or any other mentioned way;

    0 讨论(0)
  • 2021-01-23 16:32

    You should try something like:

    a[i].name = String.valueOf(i)
    
    0 讨论(0)
提交回复
热议问题