Java examples for Collection Framework:Array Fill
fill array with filling char
//package com.java2s; import java.util.Arrays; public class Main { public static void main(String[] argv) throws Exception { int fillingLength = 2; char fillingChar = 'a'; System.out.println(filler(fillingLength, fillingChar)); }//from w w w . ja v a 2s .c o m public static String filler(int fillingLength, char fillingChar) { char[] buf = new char[fillingLength]; Arrays.fill(buf, 0, buf.length, fillingChar); String res = new String(buf); return res; } }