Converting an int to String(Java)

后端 未结 2 815
太阳男子
太阳男子 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;

提交回复
热议问题