Here you can find the source of padding(int width)
Parameter | Description |
---|---|
width | amount of padding desired |
public static String padding(int width)
//package com.java2s; public class Main { private static final String[] padding = { "", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " }; /**/*from www . j a v a2 s. co m*/ * Returns space padding * * @param width * amount of padding desired * @return string of spaces * width */ public static String padding(int width) { if (width < 0) throw new IllegalArgumentException("width must be > 0"); if (width < padding.length) return padding[width]; char[] out = new char[width]; for (int i = 0; i < width; i++) out[i] = ' '; return String.valueOf(out); } }