提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
用填充字符填充数组
//package com.nowjava; /** 来自 N o w J a v a . c o m**/ 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)); } public static String filler(int fillingLength, char fillingChar) { char[] buf = new char[fillingLength]; Arrays.fill(buf, 0, buf.