This code works fine on Eclipse, but not here. Any ideas? https://code.sololearn.com/cZJt6pScpbK0/?ref=app | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

This code works fine on Eclipse, but not here. Any ideas? https://code.sololearn.com/cZJt6pScpbK0/?ref=app

1st Sep 2019, 6:49 AM
Moho
Moho - avatar
3 Answers
+ 2
or public class MySecondClass { static Scanner input = new Scanner(System.in); // visible for all methods public static void MAINS(){ ...
2nd Sep 2019, 10:06 AM
zemiak
+ 7
Create the a single Scanner in your class/main method and pass that scanner to your other methods: ... static void main(String[] args) { Scanner input = new Scanner(System.in); .... // Didn't check the names of each function.. MainMeal(input); Salad(input); Dessert(input); .... input.close(); } .... https://stackoverflow.com/a/13042296
1st Sep 2019, 11:16 PM
Edwin Pratt
Edwin Pratt - avatar
+ 6
https://code.sololearn.com/cZJt6pScpbK0/?ref=app
1st Sep 2019, 7:30 AM
Anton Böhler
Anton Böhler - avatar