repeat Asterisk by length and return a char array - Java Collection Framework

Java examples for Collection Framework:Array Length

Description

repeat Asterisk by length and return a char array

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        int len = 42;
        System.out.println(java.util.Arrays.toString(repeatAsterisk(len)));
    }/*  ww w  .j a v a2s  .  c  om*/

    private static final char SEPARATOR_CHAR_ASTERISK = '*';

    private static char[] repeatAsterisk(int len) {
        char[] chars = new char[len];
        for (int i = 0; i < len; i++) {
            chars[i] = SEPARATOR_CHAR_ASTERISK;
        }
        return chars;
    }
}

Related Tutorials