0

Please someone help me with this code .

In this java code,i have two objects but i am unable to insert inputs for both the objects...can someone say me how to do it.. https://code.sololearn.com/cmrx08ognG8s/?ref=app

10th Jul 2020, 6:57 PM
Akash Jayakrishnan
Akash Jayakrishnan - avatar
3 Respostas
+ 3
I would not ask for user input in the get method. void get(int width, int height, in depth){ this.width = width; this.height = height; this.depth = depth; } And inside main you can ask for user input.
10th Jul 2020, 7:12 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
It's because you have to define the Scanner in main method or main class. It can only be instantiated once on System.in.
10th Jul 2020, 7:04 PM
Sandra Meyer
Sandra Meyer - avatar
+ 2
Make Scanner object as static in class level..(otherwise it won't getting available to 2nd object) : Make change As: class box { static Scanner in=new Scanner(System.in); int width, height, depth; void get() { .. .. .. } Ex :Input: 2 3 4 3 4 5 Edit: Same question. It is a home work? https://www.sololearn.com/Discuss/2384191/?ref=app
10th Jul 2020, 7:08 PM
Jayakrishna 🇮🇳