help to understand this problem clear
a problem i get into a book entitled Absolute JAVA.
Quote:
Write a static method called deleteRepeats that hasa partially filled array of characters as a formal parameter and that deletes all repeated letters from the array. Because a partially filled array requires two arguments, the method should actually have two parameters: an array parameter and a formal parameter of type int that gives the number of array positions used. When a letter is deleted, the remaining letters are moved up one position to fill in the gap. This creates empty positions at the end of the array so that the less of the array is used. Because the formal parameter is partially filled array, a second formal parameter cannot be changed by a JAVA method, so have the method return the new value for this parameter. For example, consider the following code:
Code:
char a[10];
a[0] = 'a';
a[1] = 'b';
a[2] = 'a';
a[3] = 'c';
int size=4;
size = deleteRepeats(a, size);
After this code is executed, the value of a[0] is 'a', the value os [1] is 'b'. the value of a[2] is 'c', and the value of size is 3.(The value of a[3] is no longer of any concern, because the partially filled array no longer uses this indexed variable.)
here is the problem..
i cant understand it more clearly..
is there anyone who could summarize this in order for me to understand it clearly?
i dont said that you write a program for me..
i just said is to help me understand this problem clearly..
help
Let's see if you understood...
Before you can go to the next step (methods), you have to understand what you just did.
Questions:
- Do you know why my statement in my last post worked for you?
- Serjant's code was correct, he was correcting an error you had in your for statement.
- Do you completely understand everything that in the the println statement?
Statement: you didn't follow my suggestion about using the curly brackets "{}" for the "for" statement.
Luck,
CJSL