I have a ruby backround and im new to java i wrote a basic programm but somehow i get a error i cant fix! My code:
import java.util.ArrayList;
public class Musi
You need to use the get() method to get the element at a particular index from an ArrayList
. You can't use []
to get the element at a particular index, in an arraylist. Its possible only for arrays and your files
is not an array, but an ArrayList.
System.out.println( i + ". Ist: " + files.get(i));
Also, the condition in your for
loop is a bit off. files.size() <= i
is false
, and therefore, it doesn't enter the for
loop at all.
Change it to something like this.
for(int i = 0; i < files.size() ; i++){