利用好 StringBuffer 就解决了 没啥撒获得 看代码吧
import java.util.*; public class Main{ public static void main(String[] args){ int i,j,k; StringBuffer a,b; Scanner sc = new Scanner(System.in); a = new StringBuffer(); b = new StringBuffer(); a.append(sc.next()); b.append(sc.next()); boolean flag = false; for(i=0;i<a.length();i++){ String t = ""+a.charAt(i); if(b.indexOf(t)==-1){ flag = true; break; }else{ b.deleteCharAt(b.indexOf(t)); } } if(flag){ System.out.println("false"); }else{ System.out.println("true"); } } }