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); } }
4 odpowiedzi
+ 4
The L in nextline() must be in caps.
nextLine();
Remember, methods use camelCase.
+ 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);
}
}
+ 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.
+ 2
sorry for that i will delete them so as to avoid confusion in future.