I get the typical non static variable cannot be referenced from a static context error when I'm attempting to create a new object. If I make the BookWord class static, everything works. Is that OK in Java?
package javaapplication13;
public class JavaApplication13 {
public class BookWord {
private String wordCharacters;
private int count;
public BookWord(String word){
wordCharacters = word;
}
public String getWord() {
return wordCharacters;
}
public int getCount() {
return count;
}
}
public static void main(String[] args) {
BookWord existing = new BookWord("Hello"); // *** Error here ***
System.out.println("The word is " + existing.getWord());
System.out.println("The current count is " + existing.getCount());
}
}