Created
May 19, 2020 19:06
-
-
Save kryvoboker/bd01fad4d5bbc9ae30942e12b49d63a3 to your computer and use it in GitHub Desktop.
HomeWork7
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
public class Main { | |
public static void main(String[] args) { | |
int [] array = {5, 8, 6, 9, 4}; | |
System.out.println(getString(array)); | |
} | |
public static String getString (int [] array) { | |
StringBuilder sb = new StringBuilder("["); | |
for (int t : array) { | |
sb.append(t); | |
if (t != array.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