Hello all,
I am currently trying to write a loop that fills an array with 12 elements and then compares the length of that array with another array. If both arrays have equal length it prints them. If not an error code comes up. Here is my code
import java.util.*;
class myArrays
{
int allMonths;
String months;
String numbers;
int numberslength;
public void printArray(){
String[] months = new String[13];
months [1] = "January";
months [2] = "Feb";
months [3] = "Mar";
months [4] = "April";
months [5] = "May";
months [6] = "June";
months [7] = "July";
months [8] = "Aug";
months [9] = "Sept";
months [10] = "Oct";
months [11] = "Nov";
months [12] = "Dec";
///allMonths=months.length;
int array[] = new int[14];
int p=0;
//
// Arrays.fill(array, x);
// for (int x=0; x<array.length; x++) {
// Arrays.fill(array, p++);
//
// }
//
// //}
for(int i=0; i<months.length;i++){
Arrays.fill(array, p++);
if (array.length==months.length){
System.out.println("they are same length");
}
System.out.println(array[p]+"."+ months[i]);
}