0

Please, what is wrong in this code???

package com.orientales; import java.util.Scanner; public class Activity_Main { public static void main(String[] args) { Scanner myVar=new Scanner(System.in); System.out.println(myVar.nextline()); int x = 2; int y = 3; int z =x+y; System.out.println(z); } }

15th Aug 2017, 4:00 PM
Qaasim Muhammad Akorede
Qaasim Muhammad Akorede - avatar
4 odpowiedzi
+ 4
The L in nextline() must be in caps. nextLine(); Remember, methods use camelCase.
15th Aug 2017, 4:05 PM
Rrestoring faith
Rrestoring faith - avatar
+ 13
// Don't import any package in SoloLearn import java.util.Scanner; public class Activity_Main { public static void main(String[] args) { Scanner myVar=new Scanner(System.in); System.out.println(myVar.nextLine()); // use L int x = 2; int y = 3; int z =x+y; System.out.println(z); } }
15th Aug 2017, 4:04 PM
Dev
Dev - avatar
+ 4
@shobhit Not quite. nextLine() returns a string which is equal to the input it takes from whatever the input stream is. So, it's just printing the String the nextLine() method returns.
15th Aug 2017, 4:14 PM
Rrestoring faith
Rrestoring faith - avatar
+ 2
sorry for that i will delete them so as to avoid confusion in future.
15th Aug 2017, 4:15 PM
shobhit
shobhit - avatar