Method 1 - Writing our own function
Method2 - Using Arrays.asList()
public static String toString(int[] intArray) {
String separator =
",";
StringBuilder sb =
new StringBuilder("");
if (intArray != null && intArray.length > 0) {
for (int i = 0; i < intArray.length; i++) {
sb.append(intArray[i]);
if (i < (intArray.length - 1)) {
sb.append(separator);
}
}
}
return sb.toString();
}
Method2 - Using Arrays.asList()
Arrays.asList(intArray).toString()
No comments:
Post a Comment