+ 1
Where do i get input in code coach (Java)
Hello i'm having trouble resolving code coach because I don't know how to get input to work with. When i go in the code section I just have : public class Program { public static void main(String[] args) { } } How can i store the input in a variable so I can transform it ? Have a good day :)
2 ответов
+ 8
Well, you... create your own variables! Start by declaring local variables by yourself within main, e.g.
public static void main(String[] args) {
int myVar = 39;
// the rest of your solution goes here
}
If you want to get input, then use a Scanner.
Scanner sc = new Scanner(System.in);
int myVar = sc.nextInt();
When your code runs for test cases, the input will be provided automatically by SL to your corresponding scanner objects.
+ 1
Ayy thanks I was coding "nextString" instead of "nextLine" 😌