#15111: 請問錯在哪?


lingming88 (unknown)


import java.util.Scanner;
public class p0914 {

public static void main(String[] args) {
    Scanner s=new Scanner(System.in);
    String a=s.nextLine();
    System.out.println("hollo, "+a);

  }

}

#15121: Re:請問錯在哪?


anandrewboy70900 (ShowTsai)


 

1.請重複輸入

2."hello", 不是 "hollo"




#15145: Re:請問錯在哪?


lingming88 (unknown)


 

1.請重複輸入

2."hello", 不是 "hollo"



import java.util.Scanner;

public class Text1 {

public static void main(String[] args) {

    Scanner s=new Scanner(System.in);

    for(int n=0; ;n++){

    String a=s.nextLine();

    System.out.println("hello, "+a);

    if(n==10){break;}

  } 

 

 }

 

}

請問一下我可以重複了

但是測試系統說找不到結束點是怎麼一回事?

當我輸入10for迴圈會停止

後面再輸入時不會跑出hello ,




#15162: Re:請問錯在哪?


anandrewboy70900 (ShowTsai)


 

1.請重複輸入

2."hello", 不是 "hollo"



import java.util.Scanner;

public class Text1 {

public static void main(String[] args) {

    Scanner s=new Scanner(System.in);

    for(int n=0; ;n++){

    String a=s.nextLine();

    System.out.println("hello, "+a);

    if(n==10){break;}

  } 

 

 }

 

}

請問一下我可以重複了

但是測試系統說找不到結束點是怎麼一回事?

當我輸入10for迴圈會停止

後面再輸入時不會跑出hello ,


請去搜尋 hasNextLine 的用法