Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication9;
- /**
- *
- * @author trand
- */
- public class JavaApplication9 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // Bên dưới Input cố định. Nhớ lấy input từ server
- String input = "vklh0104tu`3-9gvndnji*$%^#HNd01n91n&N&15";
- // Chỉ giữ lại chữ
- StringBuilder converted = new StringBuilder();
- for (char ch : input.toCharArray()) {
- if (Character.isLetter(ch)) {
- converted.append(ch);
- }
- }
- String letters = converted.toString(); // letters là chỉ còn ký tự chữ
- // Bỏ hết ký tự lặp từ letters
- StringBuilder noDuplicated = new StringBuilder();
- for (char ch : letters.toCharArray()) {
- if (!noDuplicated.toString().contains(String.valueOf(ch))) {
- noDuplicated.append(ch);
- }
- }
- // noDuplicated.toString() đã bỏ hết ký tự lặp
- System.out.println(noDuplicated.toString());
- }
- }
Add Comment
Please, Sign In to add comment