Glad you got it working.
Type: Posts; User: Norm
Glad you got it working.
Can you write a small program for testing how to use arrays? Leave this program for now.
Put all the code for the test program in the main() method.
1)Define an array of int with 5 slots...
Only one book's name can be stored in anArray[0]. If you want more than one name stored in the array, you need to use a variable for the index instead of [0]. When a name is stored in the array at...
That statement puts the current value of books in the first slot in the array.
Do you want to save a different value of books in another slot in the array?
Where do you want to save the data...
Can you explain what you mean?
see posts #51 and #53
That is the same as doing the following:
int x;
x = 3;
x = 4;
x = 5;
and expecting x to remember it once had the values 3 and 4. That is NOT the way computers work. x can only have one value,...
theArray[theIndex++] = theValue; // save theValue in theArray and incr the index
When you store data into an array, you need to change the index's value to point to the element in the array where you want the data stored. Normally the index starts at 0 and increases by 1 for...
That is the String returned by an array of Strings toString() method.
If you want to see the contents of the array, you will need to access each element in the array one at a time using array...
That is the String returned by an int array's toString() method.
If you want to print the array's contents you will need to index into the array to access each element in the array.
Why are you...
The posted code has ONE variable that holds one String that is the value of the last name the user entered.
If you want to save more than one book name, you will need to change the program to save...
What is wrong with the program's output?
What do you want the output to look like?
Please copy the full contents of the command prompt window that shows the program's input and output and paste it here. Add some comments showing what you want the output to be.
The posted code can't be executed for testing. It is missing a main() method.
Did you have questions about the code in post#38?
Please copy the full contents of the command prompt window that shows the program's input and output and paste it here. Add some comments showing what you want the output to be.
Please copy the full text of the error message and paste it here.
Change the code so the index's value does not go past the end of the array.
At line 57 the code used an index that was past the end of the array. Remember array indexes range in value from 0 to the length-1. If an array has two elements, 0 and 1 are the valid indexes.
...
What variable are you talking about?
Use code like you used in testing how to create random numbers back in posts #18 and#22
What does the program need to have done and Where does the program need that functionality?
Often you create a method to do some task and add calls in the program where it needs that task to be...
You have tested using the random numbers, so you now should now know to create them.
What do you not understand about creating random numbers?
Can you explain what problems you are having now?
??? What does that code do? Did you have a question?
Did you change the variables as I suggested? When i1 is 9 the loop ends.
You won't want to print an infinite list of numbers.
One problem with that code is that it uses the same variable for controlling the loop and for receiving the random number. They should be different variables.
Did you run the program several...
The message must be about the IDE. You need to ask in the IDE section about the problem.