Greetings All,

I have a brain fart. I am trying to print the first and second number in the array which is [0] and [1]. I have the for loop going through each element in the array integersCount[] so I can find those positions. But do I need an if statement to find that position? Or can I just do a System.out.println(Arrays.toString[0]) and System.out.println(Arrays.toString[1])? This is just my static method(last piece of the code)to print out just those positions from the integersCount[] array for this particular class. Any suggestions possibly?

public static void SmallestDelta(int[] integersCount)
   {
      for(int i = 0; i < integersCount.length; i++  )
      {

        if
        {

        }


      }

If those are the only ones you want to print, then you don't need a loop. Using two println statements will work fine.
The items to be printed don't look right. You should be using the name of your array, not Arrays.toString

Edited 4 Years Ago by NormR1

That will just print the first element out of the array and exit the for loop right? I need to print both the 0 AND 1 position of the array. Would this work or would it only compare the data that is stored in the variable memory for i and not the array position?

if(integersCount[i] == 0)
{
System.out.println(integersCount[i]);
}

Ah okay I think this is right then...let me try this:

public static void SmallestDistance(int[] integersCount)
   {
      System.out.println(integersCount[0]);
      System.out.println(integersCount[1]);

   }
This question has already been answered. Start a new discussion instead.