Scanner sc=new Scanner(System.in); String str = sc.next(); if(str.length()>10){ System.out.println("输入的内容过多"); }else{ System.out.println("正确定输"); }