用hashset 解决 利用split()
import java.util.*; public class Main{ public static void main(String[] args){ String s; Scanner sc = new Scanner(System.in); HashSet<String> set = new HashSet(); while(true){ s = sc.next(); if(s.equals("end"))break; if(s.charAt(0)=='i'){ set.add(s.split(":")[1]); System.out.println("ok"); } if(s.charAt(0)=='d'){ set.remove(s.split(":")[1]); System.out.println("ok"); } if(s.charAt(0)=='s'){ boolean a = set.contains(s.split(":")[1]); System.out.println(a); } } } }