I have two array lists, one for employees, another for their availabilities. The arrays are of different size. I don't see the problem with that when I'm using the array of the larger size in `getItemCount()`:

```
@Override
    public int getItemCount() {
        return allEmployees.size();
    }

```

I set recycler view to get all employee items, however my availability is a shorter list. If I have 6 availability's and 12 employees everything goes smooth on the first page as it only shows the 6 employees. But when I scroll down it will crash as there is a 7th employee but no 7th availability.

Recycler View :

```
public class RecycleViewAdapter extends RecyclerView.Adapter<RecycleViewAdapter.MyViewHolder> {
    List<EmployeeModel> allEmployees;
    List<AvailabilityModel> allAvailabilitys;
    Context context;

    public RecycleViewAdapter(List<EmployeeModel> allEmployees, List<AvailabilityModel> allAvailabilitys, Context context) {
        this.allAvailabilitys = allAvailabilitys;
        this.allEmployees = allEmployees;
        this.context = context;

    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_employee, parent, false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        AvailabilityModel available = allAvailabilitys.get(position);
        EmployeeModel employee = allEmployees.get(position);
        holder.employeeID.setText(String.valueOf(allEmployees.get(position).getEID()));
        holder.firstName.setText(allEmployees.get(position).getfName());
        holder.lastName.setText(allEmployees.get(position).getlName());
        //holder.position = position;
        holder.employee = employee;

        holder.editButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, EditEmployee.class);
                intent.putExtra("Editing", employee);
                context.startActivity(intent);
            }
        });
        holder.availabilityButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, availability_screen_code.class);
                intent.putExtra("Available", employee);
                intent.putExtra("Days", available);
                context.startActivity(intent);
            }
        });
        holder.parentLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, ViewEmployee.class);
                intent.putExtra("Viewing", employee);
                context.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return allEmployees.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder{
        TextView firstName;
        TextView lastName;
        TextView employeeID;
        int position;
        ImageButton editButton;
        ImageButton availabilityButton;
        EmployeeModel employee;
        ConstraintLayout parentLayout;

        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            firstName = itemView.findViewById(R.id.fNameView);
            lastName = itemView.findViewById(R.id.lNameView);
            employeeID = itemView.findViewById(R.id.eIDView);
            editButton = itemView.findViewById(R.id.imageButton2);
            availabilityButton = itemView.findViewById(R.id.imageButton4);
            parentLayout = itemView.findViewById(R.id.parentLayout);
        }
    }
}

```

Where I'm using the position:

```
public class availability_screen_code extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
    private Spinner mondaySpinner, tuesdaySpinner, wednesdaySpinner, thursdaySpinner, fridaySpinner, saturdaySpinner, sundaySpinner;
//    private String mondayChoice, tuesdayChoice, wednesdayChoice, thursdayChoice, fridayChoice, saturdayChoice, sundayChoice;
//    private static final boolean [] choices = new boolean[6];
    private ImageButton confirmation;
    EmployeeDBAssist employeeDB;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.availability_screen);
        mondaySpinner = findViewById(R.id.mondaySpinner);
        tuesdaySpinner = findViewById(R.id.tuesdaySpinner);
        wednesdaySpinner = findViewById(R.id.wednesdaySpinner);
        thursdaySpinner = findViewById(R.id.thursdaySpinner);
        fridaySpinner = findViewById(R.id.fridaySpinner);
        saturdaySpinner = findViewById(R.id.saturdaySpinner);
        sundaySpinner = findViewById(R.id.sundaySpinner);
        confirmation = findViewById(R.id.confirm);
        //this is linked to the recycler which gets an entire list of availability!
        Bundle bundle = getIntent().getExtras();
        AvailabilityModel available = (AvailabilityModel) getIntent().getSerializableExtra("Days");
        EmployeeModel employee = (EmployeeModel) getIntent().getSerializableExtra("Available"); //this is where im using it
        employeeDB = new EmployeeDBAssist(availability_screen_code.this);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.availableTimes, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        //monday
        mondaySpinner.setAdapter(adapter);
        mondaySpinner.setOnItemSelectedListener(this);
        String availableString = available.getMonday();
        mondaySpinner.setSelection(getIndex(mondaySpinner, availableString));
        Toast.makeText(this, availableString, Toast.LENGTH_SHORT).show();

        //tuesday
        tuesdaySpinner.setAdapter(adapter);
        tuesdaySpinner.setOnItemSelectedListener(this);
        //wednesday
        wednesdaySpinner.setAdapter(adapter);
        wednesdaySpinner.setOnItemSelectedListener(this);
        //thursday
        thursdaySpinner.setAdapter(adapter);
        thursdaySpinner.setOnItemSelectedListener(this);
        //friday
        fridaySpinner.setAdapter(adapter);
        fridaySpinner.setOnItemSelectedListener(this);
        //saturday
        saturdaySpinner.setAdapter(adapter);
        saturdaySpinner.setOnItemSelectedListener(this);
        //sunday
        sundaySpinner.setAdapter(adapter);
        sundaySpinner.setOnItemSelectedListener(this);

        confirmation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                AvailabilityModel availabilityModel;
                try{
                    availabilityModel = new AvailabilityModel(-1, employee.getEID(), mondaySpinner.getSelectedItem().toString(), tuesdaySpinner.getSelectedItem().toString(), wednesdaySpinner.getSelectedItem().toString(), thursdaySpinner.getSelectedItem().toString(), fridaySpinner.getSelectedItem().toString(), saturdaySpinner.getSelectedItem().toString(), sundaySpinner.getSelectedItem().toString());
                    EmployeeDBAssist employeeDBAssist = new EmployeeDBAssist(availability_screen_code.this);
                    employeeDBAssist.updateAvailability(employee.getEID(),mondaySpinner.getSelectedItem().toString(), tuesdaySpinner.getSelectedItem().toString(), wednesdaySpinner.getSelectedItem().toString(), thursdaySpinner.getSelectedItem().toString(), fridaySpinner.getSelectedItem().toString(), saturdaySpinner.getSelectedItem().toString(), sundaySpinner.getSelectedItem().toString());
                    Toast.makeText(availability_screen_code.this, String.valueOf(employee.getEID()) + " " + mondaySpinner.getSelectedItem().toString()+ " " + tuesdaySpinner.getSelectedItem().toString()+ " " + wednesdaySpinner.getSelectedItem().toString()+ " " + thursdaySpinner.getSelectedItem().toString()+ " " + fridaySpinner.getSelectedItem().toString()+ " " + saturdaySpinner.getSelectedItem().toString()+ " " + sundaySpinner.getSelectedItem().toString(), Toast.LENGTH_SHORT).show();
                    boolean success = employeeDBAssist.addAvailability(availabilityModel);
                }
                catch (Exception e){
                    Toast.makeText(availability_screen_code.this, "Error Setting Availability", Toast.LENGTH_SHORT).show();
                }
                Intent i = new Intent(availability_screen_code.this,activity_main_code.class);
                startActivity(i);

                Toast.makeText(availability_screen_code.this, String.valueOf(employee.getEID()) + " " + mondaySpinner.getSelectedItem().toString()+ " " + tuesdaySpinner.getSelectedItem().toString()+ " " + wednesdaySpinner.getSelectedItem().toString()+ " " + thursdaySpinner.getSelectedItem().toString()+ " " + fridaySpinner.getSelectedItem().toString()+ " " + saturdaySpinner.getSelectedItem().toString()+ " " + sundaySpinner.getSelectedItem().toString(), Toast.LENGTH_SHORT).show();
            }
        });
    }

```

`availability` table has 2 values and `employees` 7. In `getItemCount` I'm using the size of my employee table. However, I need to get the position of my availability so that I can use it in another class. It will only work for the first two entries. Once I scroll down it throws :

> 
> java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
> 
> 
> 

Adding an availability for every employee would defeat the purpose of my project. How to solve this with the use of two separate arrays of different size?