How to concatenate int values in java?
The easiest (but somewhat dirty) way:
String result = "" + a + b + c + d + e
Edit: I don't recommend this and agree with Jon's comment. Adding those extra empty strings is probably the best compromise between shortness and clarity.
Michael Borgwardt's solution is the best for 5 digits, but if you have variable number of digits, you can use something like this:
public static String concatenateDigits(int... digits) { StringBuilder sb = new StringBuilder(digits.length); for (int digit : digits) { sb.append(digit); } return sb.toString();}
This worked for me.
int i = 14;int j = 26;int k = Integer.valueOf(String.valueOf(i) + String.valueOf(j));System.out.println(k);
It turned out as 1426