Is it possible? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Is it possible?

i have a doubt is it possible to use operators in getting input . i tried but the output is not getting https://code.sololearn.com/c9mV2Wt3kJ1u/?ref=app what is mistakes i did in this code

27th Sep 2018, 4:55 PM
srinu rocky
srinu rocky - avatar
6 Réponses
0
you can not, x is an object of Scanner class, you can use methods that are available in that class x + = 2; Incompatible types. Required: java.util.Scanner Found: int https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
27th Sep 2018, 5:03 PM
Daniel (kabura)
Daniel (kabura) - avatar
0
"Required:java.until.Scanner" is thos i have to add in my coding
27th Sep 2018, 5:06 PM
srinu rocky
srinu rocky - avatar
0
no, this is an error message, you are trying to add the number 2 (int) to x (java.util.Scanner class) it is not possible,
27th Sep 2018, 5:09 PM
Daniel (kabura)
Daniel (kabura) - avatar
0
k thx bro
27th Sep 2018, 5:10 PM
srinu rocky
srinu rocky - avatar
0
you can save it, e.g. System.out.print (x.nextInt () + 2); or int number = x.nextInt (); System.out.print (number);
27th Sep 2018, 5:12 PM
Daniel (kabura)
Daniel (kabura) - avatar
27th Sep 2018, 5:33 PM
srinu rocky
srinu rocky - avatar