Java printing a string containing multiple integers

后端 未结 7 1718
别那么骄傲
别那么骄傲 2021-01-19 08:16

Just starting learning java today and can\'t seem to figure this out. I am following the tutorial on learnjavaonline.org which teaches you a few things and then asks you to

相关标签:
7条回答
  • 2021-01-19 08:52

    I would use String.valueOf to explicitly cast each numeric value to String before being added. Like so:

    String output = h + String.valueOf( three ) + String.valueOf( one ) + String.valueOf( ten ) + " " + "w" + String.valueOf( zero ) + "r" + String.valueOf( won ) + "d " + String.valueOf( two ) + " " + t;
    
    0 讨论(0)
提交回复
热议问题