+ 3
What is wrong in this code? Plz help
import java.util.Scanner; public class Mypro { public static void main (String[] args) { Scanner myo=new Scanner(System.in); Scanner myo2=new Scanner(System.in); int firstnumber; int secondnumber; firstnumber=myo.nextInt(); secondnumber=myo2.nextInt(); System.out.println(firstnumber*secondnumber); } }
3 Answers
+ 13
can't have 2 System.in Scanners. Remove myo2 and change:
secondnumber = myo.nextInt ();
đ
+ 3
Just use one scanner object.
- 2
also, besides the instance of two scanners needing to be one, you need a semi colon at the end of the curly brace for the class.