0

How can I give input after writing this program and running it.

import java.util.Scanner; public class ScannnerUse { public ScannnerUse(){ Scanner input = new Scanner(System.in); int x=0,y=0; System.out.print("Enter the value of x:"); x=input.nextInt(); System.out.print("Enter the value of y:"); y=input.nextInt(); int sum=x+y; System.out.print("Sum of x+y="+sum); } }

4th Dec 2019, 1:33 PM
Sandesh Raj
Sandesh Raj - avatar
2 Respostas
0
Add main method. You need to call method in main method through its object.. but here its a constructor. so just create an object in main method..... Expecting Do you know how to do it?
4th Dec 2019, 1:44 PM
Jayakrishna 🇮🇳