Advertisement
DanikYakush

Task40

Jul 12th, 2022
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. public class Task40 {
  2.     public static void main(String[] args) {
  3.  
  4.         String s = "  A pilot  in the 123   awakes one morning to see, standing before him, the most extraordinary little fellow. \"Please,\" asks the word, \"draw me a sheep.\" And the pil345345345ot realizes that when life's events are too difficult to understand, 345 is no word but to succumb to their mysteries. He pulls out pencil and paper... And 234 begins this wise and enchanting fable that, in teaching the secret of what is really 234 in life, has changed forever the world for its readworders.";
  5.         System.out.println(s);
  6.         s = s.trim();
  7.         System.out.println(s);
  8.         String newS = new String();
  9.  
  10.         char[] array = s.toCharArray();
  11.  
  12.         for (int i = 0; i < array.length; i++) {
  13.             if (array[i] == ' ' && array[i - 1] == ' ') {
  14.                
  15.             } else {
  16.                 newS += array[i];
  17.             }
  18.  
  19.         }
  20.         System.out.println(newS);
  21.  
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement