MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

/**
 * Output:
       
Word       Length
a          1
aaa        3
aaaaaaaaaa 35
       
 */

public class MainClass {
    public static void main(String args[]) throws Exception {

        String[] words = new String[] { "a", "aaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" };
        System.out.printf("%-10s %s\n", "Word", "Length");
        for (String word : words)
            System.out.printf("%-10.10s %s\n", word, word.length());

    }
}