SHARE
TWEET

Untitled

a guest Jul 17th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2.  
  3.  
  4. public class examPrep {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         String input = scanner.nextLine();
  8.         printResult(input);
  9.     }
  10.  
  11.     static void printResult(String input) {
  12.         StringBuilder sb = new StringBuilder(input.charAt(0)+"");
  13.         for (int i = 0; i < input.length(); i++) {
  14.             char currentChar = input.charAt(i);
  15.             if (sb.toString().charAt(sb.toString().length()-1)!=currentChar){
  16.                 sb.append(currentChar);
  17.             }
  18.         }
  19.         System.out.println(sb);
  20.     }
  21.  
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top