This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

wang min

Greenhorn
+ Follow
since Jul 27, 2021
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by wang min

Adding 6 numbers as 1,2,3,4,5,6
Need to remove values in loop with a difference of 2.

Desired Result : Removal of 3 in the first loop followed by 6 followed by 4 followed by 2 followed by 5 & at last by 1.

Here's my code:


Adding 6 numbers as 1,2,3,4,5,6
Need to remove values in loop with a difference of 2.

Desired Result : Removal of 3 in the first loop followed by 6 followed by 4 followed by 2 followed by 5 & at last by 1.

Here's my code:

while(array.length ! = 1)
{

   for(int i =2; i<array.length; i=i+2)
   {
        array = ArrayUtils.remove(array, i);
        System.out.println("Content of Array after removing an object : "
           + Arrays.toString(array));
   }              
}
Getting result as

Content of Array after removing an object : [1, 2, 4, 5, 6]

Content of Array after removing an object : [1, 2, 4, 5]

Content of Array after removing an object : [1, 2, 5]

Content of Array after removing an object : [1, 2]

thanks for help
2 months ago