Here you can find the source of createRepeatedString(char c, int length)
Parameter | Description |
---|---|
c | the character |
length | the length |
public static String createRepeatedString(char c, int length)
//package com.java2s; /******************************************************************************* * Copyright (c) 2016 BestSolution.at and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w.j a v a 2s . c o m * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation *******************************************************************************/ import java.util.Arrays; public class Main { /** * Create a string of the same char * * @param c * the character * @param length * the length * @return the created string * @since 2.4.0 */ public static String createRepeatedString(char c, int length) { char[] vals = new char[length]; Arrays.fill(vals, c); return String.valueOf(vals); } }