|
|
back to boardWA3 import java.util.List; import java.util.ArrayList; import java.util.Scanner; public class Spion { public static void main(String[] args) { Scanner in = new Scanner(System.in); List<String>shifr = new ArrayList(); String word = in.next();
shifr.add(""+word.charAt(0));
for(int i =1;i<word.length();i++){ String s =""+word.charAt(i); shifr.add(s);
if(shifr.get(shifr.lastIndexOf(s)).equals(shifr.get(shifr.indexOf(s))) && shifr.lastIndexOf(s)==shifr.indexOf(s)+1) { shifr.remove(shifr.get(shifr.lastIndexOf(s))); shifr.remove(shifr.get(shifr.indexOf(s)));
};
}
for(String n: shifr){
System.out.print(n); }
} } what's wrong? |
|
|