We have three ways to become a variable of type int String type it too, so what are their differences?
1.int i = 5;
2.String i1 = "" + i;
3.String i2 = String.valueOf(i);
4.String i3 = Integer.toString(i);
The third and fourth lines without any distinction, because String.valueOf (i) also calls Integer.toString (i) to achieve.
The second line of code is actually a String i1 = (new StringBuilder ()). Append (i) .toString () ;, first create a StringBuilder object, and then calling the append method, then call toString method.