Hei I'm a beginner in Java and I have homework and I spent all day trying to figure out the solution and I couldn't. I'm so frustrated Can someone help me? Converting from any table in Int [] to string for eksmpel : int [] a = { 1,2,3} to String s = [1,2,3] I didn't know how to put the comma, it always shows a trailing comma at the end or at the beginning a trailing comma as well as parentheses.
This is my code :
public class Test11 {
public static String til(int[] tabell) {
String str = "";
String na1 = "[";
String na2 = "]";
String na3 = ",";
String str3 = "";
for (int i = 0; i < tabell.length; i++) {
str += "," + tabell[i];
}
return str;
}
public static void main(String[] args) {
int[] tab = { 1, 2, 3 };
System.out.println(til(tab));
}
}