62,634
社区成员




public class test2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
String str1;
String s=in.nextLine();
do {
str1=s;
System.out.println(str1);
System.out.println("若想更改str1的值请直接写,若不更改直接回车");
}while(!(s=in.nextLine()).equals(""));
in.close();
}
}
测试结果;
111
111
若想更改str1的值请直接写,若不更改直接回车
222
222
若想更改str1的值请直接写,若不更改直接回车
public class test2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
String str1=in.nextLine();
do {
System.out.println(str1);
System.out.println("若想更改str1的值请直接写,若不更改直接回车");
}while((str1=in.nextLine())!="");
}
}