I am creating an array in the class with main method
Word attempts = new Word (26);
Field in class Word is
private String [] attempts;
Constructor in class Word is
public Word (int a){
attempts = new String [a];
create(attempts);
}
Where create is a method that makes every array element an empty String (""). In class Word I've also got a getAttempts() method for accessing the attempts array. Now, I want to make class Letter where i pass the before created array Word [] in a for loop. I tried with Word.getAttempts()[i], but I get an error Cannot make a static reference to the non-static method getAttempts() from the type Word. To my understanding when a method is static, you do not have to create an object before calling the method. I have no idea how to pass the array created in Main method to this Letter class. Any help?
edit: Here is my Word class
public class Word {
private String [] attempts;
public String[] getAttempts() {
return attempts;
}
public void create (String [] attempts){
for (int i=0; i<attempts.length; i++){
attempts[i]="";
}
}
public Word (int a){
attempts = new String [a];
create(attempts);
}
}
To sum up, I am creating an array in class with Main method that is type of Word, and I want to pass that array to separate class Letter.