-2

If I have

'String t = "";
int i = 1;
double d = 3.3;'

May I do t = t + " " + i + " " + d or I need to cast?

Benjamin
  • 2,257
  • 1
  • 15
  • 24
Tatanan
  • 207
  • 2
  • 10

3 Answers3

3

Yes you can..No need to cast..

Simply you can do like you said, t = t + " " + i + " " + d;

Nadun
  • 300
  • 4
  • 15
0

No. You don't

t = t + " " + i + " " + d --> "New" String = string + " " + String.valueOf(integer) + " " + String.valueOf(double)
TheLostMind
  • 35,966
  • 12
  • 68
  • 104
0

Try it :

    double total = 10; 
    String total = String.valueOf(total);
Benjamin
  • 2,257
  • 1
  • 15
  • 24