Arrays shown in output after user input

<>

This question is an exact duplicate of:

Answers


This:

String monthChoice = monthsArray[month - 1];

Should be:

String monthChoice = monthsArray[month];

Because the first month is empty.

Also, I don't understand this for loop, since you don't even use the i variable, and you don't need to repeat that action multiple times:

for (int i=0; i < monthsArray.length; i++)

Consider this: A user enters the number 1 and you assign it to your month variable so now month = 1. The first line in your for loop now asks for monthsArray[month - 1] which is monthsArray[1-1] which turns into monthsArray[0]. The 0th element of your monthsArray is an empty string "". When you print this as monthChoice you get only the 2nd part of your string so it looks like you are getting a result you don't want.


Need Your Help

OutOfBoundsException with ALS - Flink MLlib

scala indexoutofboundsexception recommendation-engine apache-flink flinkml

I'm doing a recommandation system for movies, using the MovieLens datasets available here :

htaccess : combining permanent domain change and stripping of www

.htaccess url-rewriting

I I use the code below to strip the www from my (new) domain. Now I want to redirect the old domain tot the new one too. Can't get it to work. Is it possible to do both?