import java.util.*;
public class ProblemJ3 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String Corr; //Integer will be used to input x and y coordinates in arrays.
int DropsOfPaint = input.nextInt(); //Getting the total number of coordinates needed.
//Creating arrays to hold x and y values.
int ArrayOfCorrX[] = new int[DropsOfPaint];
int ArrayOfCorrY[] = new int[DropsOfPaint];
//asking user for a number of x and y coordinates, depending on DropsOfPaint.
for ( int i = 0; i <= DropsOfPaint; i++ )
{
String[] parts = new String[DropsOfPaint];
Corr = input.nextLine();
parts = Corr.split(",");
System.out.println(parts.length);
int num1 = Integer.valueOf(parts[1]);
int num2 = Integer.valueOf(parts[1]);
ArrayOfCorrX[i] = num1;
ArrayOfCorrY[i] = num2;
}
//Setting initial value before maximum and minimum number search.
int MinX = ArrayOfCorrX[0];
int MaxX = ArrayOfCorrX[0];
int MinY = ArrayOfCorrY[0];
int MaxY = ArrayOfCorrY[0];
//Compares and saves a new minimum or maximum each time if there is available option.
for ( int j = 0; j < DropsOfPaint; j++ )
{
if (ArrayOfCorrX[j] < MinX) MinX = ArrayOfCorrX[j];
if (ArrayOfCorrX[j] > MaxX) MaxX = ArrayOfCorrX[j];
if (ArrayOfCorrY[j] < MinY) MinY = ArrayOfCorrY[j];
if (ArrayOfCorrY[j] > MaxY) MaxY = ArrayOfCorrY[j];
}
//Out puts size of canvas from bottom left corner to top right corner.
System.out.println((MinX - 1) + ", " + (MinY - 1));
System.out.println((MaxX + 1) + ", " + (MaxY + 1));
input.close();
}
I keep receiving this error,
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at ProblemJ3.main(ProblemJ3.java:24)
I'm not sure how to solve this.