Advertisement
advictoriam

Untitled

Jan 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. public class Numbers
  2. {
  3.    /**
  4.       Produces a string containing the numbers in an array,
  5.       separated by commas, such as "1,4,9"
  6.       @param values an array of integer values
  7.       @return a string containing the array elements, separated by
  8.       commas.
  9.     */
  10.    public String separateWithCommas(int[] values)
  11.    {
  12.       String str = "";
  13.       for(int a : values){str += a + ",";}
  14.       return (str.length() != 0) ? str.substring(0, str.length() - 1) : "";
  15.    }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement