What if user enters From/To as -1 9999
or 4 1
Should the program detect those invalid inputs and give an error message? Or just let the code throw an exception?
Another point - the program...
Type: Posts; User: Norm
What if user enters From/To as -1 9999
or 4 1
Should the program detect those invalid inputs and give an error message? Or just let the code throw an exception?
Another point - the program...
Some comments:
The code does not check the user's input for validity. EG in range and in order
This statement does a lot of extra work:
It reads an int, creates an Integer to hold that int and...
Glad you got it working.
A working solution might be helpful for others.
That is not true. A program can ask many questions without declaring any variables.
A variable must be declared before it is used.
Asking a question and using a variable do not need to be...
Did you try it?
The code would like like this:
print the message
read user's response to the message
If you print the value that was read, it will appear on the console 2 times ( that is the...
When you type in the input 0 and 3, they are displayed on the console where and when they are typed.
To have them appear after the messages: From where? and To where?
you need to print the...
I don't see where the problem is. The console output looks as expected.
What do you think the output should look like? Can you post what you expect to see?
Please copy the console's contents and paste it here. No images. Text can not be copied from an image to include in a response.
Please post the new code and the contents of the console from...
The code reads the 0 before it prints out the From where message.
The code to read the 0 is outside of the loop. Add a print statement after the loop that prints out the contents of the array....
It does for me. Can you run the program, copy the output window and paste it here so I can see?
It returns -1 if this list does not contain the element.
How else can it say the value was not found?
inclusive means it includes that value
exclusive means it does not include that value...
Read the API doc for the indexOf method. It clearly says that a -1 can be returned.
Add some print statements that print out the values of all the variables the code uses so that you can see what...
That says the error was at line 27 where the code calls the subList method.
You can see the contents of the list by printing it after the end of the loop that gets its contents.
Look at the API...
What line did that error happen on? How did the value of -1 come to be used as an index?
The message says an invalid index of -1 was used on that line. The valid indexes range from 0 to the length...