002 unresolved compilation problem, it cant be resolved

  • cannot be resolved
int price;
//Scanner in = new Scanner(System.in);
price = in.nextInt();
System.ou.println("100-" + price + "=" + (100-price));  
  • reson:

You must difine it before using it.

  • principle:

Scanner是一个类,一个开源代码,为了获取控制台输入。用它创建一个对象(in),System.in可以看做一个参数(系统输入流),这个参数是键盘输入内容,可以用in.nextLine()方法等待用户输入,如果用String XX来接收就是:String XX=in.nextLine()。

你可能感兴趣的:(002 unresolved compilation problem, it cant be resolved)