Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _02_SequencesEqualStrings {
- public static void main(String[] args) {
- try(Scanner reader = new Scanner(System.in)){
- String input = reader.nextLine();
- String[] strArray = input.split(" ");
- String lastElement = strArray[0];
- for (String element : strArray) {
- if (!element.equals(lastElement)) {
- System.out.println();
- }
- System.out.print(element + " ");
- lastElement = element;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment