java Scanner 遇到奇怪问题,不能输入
packagelearning;importjava.util.Scanner;publicclasslearn{publicstaticvoidmain(String[...
package learning;
import java.util.Scanner;
public class learn {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Please select the type you need to convert :");
System.out.println("1. Bin -> Dec");
System.out.println("2. Oct -> Dec");
System.out.println("3. Hex -> Dec");
System.out.print("\nOption : ");
int n=scan.nextInt();
if(n==1)
{
System.out.print("Plaese enter a String :");
String bin = scan.nextLine();
System.out.println(bin);
}
scan.close();
}
}
‘就像图片的那样,我不能输入东西了,不知道为什么,我用的是eclipse 展开
import java.util.Scanner;
public class learn {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Please select the type you need to convert :");
System.out.println("1. Bin -> Dec");
System.out.println("2. Oct -> Dec");
System.out.println("3. Hex -> Dec");
System.out.print("\nOption : ");
int n=scan.nextInt();
if(n==1)
{
System.out.print("Plaese enter a String :");
String bin = scan.nextLine();
System.out.println(bin);
}
scan.close();
}
}
‘就像图片的那样,我不能输入东西了,不知道为什么,我用的是eclipse 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询