java flag

Solutions on MaxInterview for java flag by the best coders in the world

showing results for - "java flag"
Jonathan
17 Jul 2019
1Inside the loop use this code only:
2
3isFound = (a[i] == valueToRemove);
4if (isFound) {
5    a[i] = 0;
6    break;
7}
8isFound is the flag and it gets true if the array item a[i] is equal to valueToRemove.
9If this flag is true it changes the value of the item to 0 enter code hereand exits the loop.
10I used a for the array, change it to the name of your variable.
11I guess arraySize is a variable holding the size of the array.