-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWordLengthRunner.java
More file actions
34 lines (25 loc) · 950 Bytes
/
WordLengthRunner.java
File metadata and controls
34 lines (25 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;
import static java.lang.System.*;
public class WordLengthRunner
{
public static void main( String args[] )
{
WordLength[] words = {new WordLength("freddy"), new WordLength("at"), new WordLength("elephant"),
new WordLength("whoooooodat"), new WordLength("alice"), new WordLength("tommy"),
new WordLength("bobby"), new WordLength("it"), new WordLength("at"), new WordLength("about"),};
out.println("Before:");
for(int i=0; i<10; i++)
{
System.out.println(words[i]);
}
Arrays.sort(words); // only works if Comparable!!
out.println("\n\nAfter:");
for(int i=0; i<10; i++)
{
System.out.println(words[i]);
}
}
}