如何判断字符串有没有空格 粗暴法: public static void main(String[] main) { String str = "fgh j"; if(str.contains(" ")) { System.out.println("Y"); } }