Help with a certain java problem

So for my class, I have to take a picture and swap colors from red to green, blue to red, and green to blue for each pixel.

This is what I have:

public void swapRGB()
  {
    Pixel[] pixelArray = this.getPixels();
    Pixel pic = null;
    int value = 0;
    
    for(int index = 0; index < pixelArray.length; index = index + 1)
    {
      pic = pixelArray[index];
      
      int colorGreen = pic.getGreen();
      int colorBlue = pic.getBlue();
      int colorRed = pic.getRed();
      
      pic.setRed(colorGreen);
      pic.setBlue(colorRed);
      pic.setGreen(colorBlue);
    }
  }

Which works great, now for the second part I have to create another method that allows me to input a number of how many swaps I want. What is wrong is that the picture for the second method doesn’t change colors at all when I use my second method which is:

public void swapRGB2(int numSwaps)
  {
    for(int num = 0; num <= numSwaps; num = num + 1)
    {
     this.swapRGB(); 
    }
  }

When I use the first method it works flawlessly. Second method leaves the pictures unchanged. What am I doing wrong?

Check out your for loop in your swapRGB method.

Perhaps ‘refactoring’ the behavior our of that for loop into its own method called swapRGB might be beneficial. I would then consider renaming the original swapRGB method to be named swapAllPixels or something like that.

numSwaps is the number of how many times the program should swap the colors, so it can be whatever the user wants it too.

Is numSwaps divisible by 3?