0

[Java] [Help Please] User Input Errors

I came up with a practice problem and have been trying to solve it but I keep getting errors. What am I doing wrong? Also, do you see any points where I'm using bad programming practices? If so, how could I do it the correct way? Code: https://pastebin.com/5HSZfHhR Error: https://pastebin.com/Lhbs1CZE Edit: Updated the code.

15th May 2018, 4:26 PM
Tommy
Tommy - avatar
2 odpowiedzi
0
In your code the line String stringUI = System.out.println("Please input a String: "); generate the error, since the return type of function println is void. So you cannot convert void to String. There is one more error in your code you declare String array 'sInputArray' 2 times in your code.
15th May 2018, 6:32 PM
Vijay Dangi
Vijay Dangi - avatar
0
Hmm I thought: String[] sInputArray; created the array then: String[] sInputArray = new String[stringUI]; Added stringUI to the array like append does in Python for lists. Is that not the case? If not, what can be used to add it to the array? As for: "In your code the line: String stringUI = System.out.println("Please input a String: "); generate the error, since the return type of function println is void. So you cannot convert void to String." How can I make it as a String rather than void..? I don't really understand what void does. I know it means does not return but that's about the extent of my knowledge.. Thank you for your reply.
15th May 2018, 9:14 PM
Tommy
Tommy - avatar