why is it not working? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why is it not working?

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scan = new Scanner (System.in); String x = scan.nextLine(); char y = scan.nextChar(); Shirt s = new Shirt(x, y); System.out.println ("Color: " + s.color); System.out.println ("Size: " + s.size); } } public class Shirt{ String color; char size; Shirt (String color, char size){ this.color = color; this.size = size; } }

1st May 2020, 12:32 PM
Yahel
Yahel - avatar
5 Answers
+ 3
char y = scan.next().charAt(0); You cannot input char like that ,read more https://www.google.com/amp/s/www.geeksforgeeks.org/gfact-51-java-scanner-nextchar/amp/
1st May 2020, 12:51 PM
Abhay
Abhay - avatar
+ 1
Martin Taylor thank you!
2nd May 2020, 11:45 AM
Yahel
Yahel - avatar
1st May 2020, 1:05 PM
Yahel
Yahel - avatar
0
https://code.sololearn.com/c1L9gm0YYiws/?ref=app Martin Taylor thank you! But now I have an Expectation... is it okay but Sololearn can't run it?
1st May 2020, 1:17 PM
Yahel
Yahel - avatar
0
Martin Taylor so I just need to remove the "pubic" from the shirt class and then everything should be fine?
1st May 2020, 3:23 PM
Yahel
Yahel - avatar