```
 cpu0minSeek.setMax(frequencies.size());
 cpu0minSeek.setProgress(frequencies.indexOf(cpu0MinFreq));
    cpu0minSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress,
                boolean fromUser) {
            cpu0min.setText(frequencies.get(progress).substring(0, frequencies.get(progress).length() - 3) + "Mhz");

        }

```

The idea is:

I have a seekBar and a textView

I retrieve list of available frequencies and set max progress of seekBar to size of the list. On progress changed i set text on textView to frequency from list with same index as progress in seekbar

I'm getting **indexOutOfBoundException** when seekbar reaches max progress

I know the reason why this is happening, its because index becomes same as size so it doesn't exist, but i don't understand how to fix it