javamethodsintargumentsiunknown

Java unknown number of arguments method


How can i make a method with a string and unknown number of intarguments?

Thanks.


Solution

  • public void printXXX(char c, int... ints) {
        for (int i : ints) {
            for (j = 0; j < i; j++) {
                System.out.print(c);
            }
            System.out.println();
        }
    }