+ 2
Java
import java.util.Scanner; public class input { public static void main(String[] args) { System.out.println("hello"); Scanner sr = new Scanner(System.in); System.out.println("enter your value1"); int a = sr.nextInt(); System.out.println("enter yourvalue2"); int b = sr.nextInt(); int sum= a+b; System.out.println(sum); } } Why I'm getting error???
7 odpowiedzi
+ 3
I work's fine for me
what error are u getting
+ 2
Musaif have a look
No errors
https://code.sololearn.com/crCeDl8t8TQA/?ref=app
+ 2
int a, b;
try { a = sr.nextInt(); } catch (Exception e) { a = 0; }
try { b = sr.nextInt(); } catch (Exception e) { b = 0; }
System.out.println("enter your value 1 : " + a);
System.out.println("enter your value 2 : " + b);
+ 2
it is work
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
System.out.println("hello");
Scanner sr = new Scanner(System.in);
System.out.println("enter your value1");
int a = sr.nextInt();
System.out.println("enter yourvalue2");
int b = sr.nextInt();
int sum= a+b;
System.out.println(sum);
}
}
+ 1
Java Tutorial
https://www.sololearn.com/learning/1068
Exception Handling
https://www.sololearn.com/learning/1068/2175/4301/1
happy coding
:)
0
But for me it's showing scanner error
0
Thank you sooooo much guys