Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Удалить повторные вхождения слов строки*/
- import java.util.*;
- public class str1 {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- System.out.println("Введите строку");
- String s = in.nextLine();
- StringTokenizer st = new StringTokenizer(s, " ");
- List<String> list = new LinkedList<String>();
- while(st.hasMoreTokens()) {
- String buf = st.nextToken();
- if(!list.contains(buf))
- list.add(buf);
- }
- for(String i: list) System.out.print(i + " ");
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment