Timur69

string

Apr 2nd, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. package tasks3;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Hello1 {
  6.     public static void main(String[] args) {
  7.  
  8.         Scanner scanner = new Scanner(System.in);
  9.         String a = scanner.nextLine();
  10.         String[] strings = a.split("\\.");
  11.         for (String word : strings) {
  12.             String head = word.substring(0, 1).toUpperCase();
  13.             String tail = ltrim(word);
  14.  
  15.             System.out.println(head + tail.substring(1));
  16.         }
  17.     }
  18.  
  19.     public static String ltrim(String s) {
  20.         int i = 0;
  21.         while (i < s.length() && Character.isWhitespace(s.charAt(i))) {
  22.             i++;
  23.         }
  24.         return s.substring(i);
  25.     }
  26. }
Add Comment
Please, Sign In to add comment