Advertisement
lobaev

Untitled

Mar 25th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. import java.util.Arrays;
  2.  
  3. public class Test {
  4.  
  5. public static void main(String[] args) throws Exception {
  6. Sentence s1 = new Sentence(" Hello world !"); //order = 5
  7. Sentence s2 = new Sentence("Abc def! ghijk"); //order = 5
  8. Sentence s3 = new Sentence(" Yaho"); //order = 4
  9. Sentence s4 = new Sentence("Computer "); //order = 8
  10. Sentence s5 = new Sentence(""); //order = 0
  11. Sentence[] arr = new Sentence[]{s1, s2, s3, s4, s5};
  12. Arrays.sort(arr);
  13. for (Sentence s : arr) {
  14. System.out.println(s);
  15. }
  16. }
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement