i am looking to make a string of this, so it will let me print formatArray() in a print sentence. But im not quiet sure how to make a string of this, and stop it from printing the information on its own.
this is the sentence i want to use;
system.out.println("your numbers are"+formatArray())
here is my code.
public static void formatArray(int[] tallrekke){
for(int i=0; i<tallrekke.length; i++){
if(i>0 && i < tallrekke.length -1) {
System.out.print(", ");
}
else if (i> tallrekke.length -2) {
System.out.print(" og ");
}
System.out.print(tallrekke[i]);
}
}