+ 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); } }

18th Mar 2017, 4:57 AM
sal sal
sal sal - avatar
3 Answers
+ 13
can't have 2 System.in Scanners. Remove myo2 and change: secondnumber = myo.nextInt (); 😃
18th Mar 2017, 5:07 AM
Nikolay Nachev
Nikolay Nachev - avatar
+ 3
Just use one scanner object.
18th Mar 2017, 5:19 AM
Rrestoring faith
Rrestoring faith - avatar
- 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.
18th Mar 2017, 5:45 AM
Paul Isaac
Paul Isaac - avatar