1.导入Scanner包 import java.util.Scanner; Scanner sc=new Scanner(System in); 创建对象 String str =sc.nextline();//接收对象