Skip to content

Instantly share code, notes, and snippets.

@mariiaKolokolova
Created May 22, 2020 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariiaKolokolova/f82278d4e36b69ff913788ef030152c3 to your computer and use it in GitHub Desktop.
Save mariiaKolokolova/f82278d4e36b69ff913788ef030152c3 to your computer and use it in GitHub Desktop.
package maricka.kolokolova;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
System.out.println("Arrays.toString: " + Arrays.toString(a));
System.out.println("myArray: " + myArray(a));
}
public static String myArray(int[] a) {
StringBuffer sb = new StringBuffer("[");
for (int i = 0; i < a.length; i++) {
sb.append(a[i]);
if (i < a.length - 1) {
sb.append(", ");
}
}
sb.append("]");
return sb.toString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment