Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Numbers
- {
- /**
- Produces a string containing the numbers in an array,
- separated by commas, such as "1,4,9"
- @param values an array of integer values
- @return a string containing the array elements, separated by
- commas.
- */
- public String separateWithCommas(int[] values)
- {
- String str = "";
- for(int a : values){str += a + ",";}
- return (str.length() != 0) ? str.substring(0, str.length() - 1) : "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement