Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2005, 2012 IBM Corporation 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
 *
    
 *******************************************************************************/

public class Main {
    /**
     * Returns the given number of spaces.
     * 
     * @param spaces
     * @return
     */
    public static String getNSpaces(int spaces) {
        return getNChars(spaces, ' ');
    }

    /**
     * Returns <code>count</code> copies of the given character.
     * 
     * @param count
     * @param ch
     * @return
     */
    public static String getNChars(int count, char ch) {
        StringBuffer buf = new StringBuffer(count);
        for (int i = 0; i < count; i++)
            buf.append(ch);
        return buf.toString();

    }
}