-
-
Save mariiaKolokolova/f82278d4e36b69ff913788ef030152c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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