Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    public static void main(String args[]) {
        String s = "java2s.com";
        int l;
        l = s.length();
        for (int i = 0; i < l; i++) {
            int padding = s.length() - i;
            if (padding > 0) {
                System.out.printf("%" + padding + "s", " ");
            }
            for (int j = 0; j < i; j++) {
                System.out.printf("%c ", s.charAt(j));
            }
            System.out.printf("%c\n", s.charAt(i));
        }
    }
}