[java] java calling a method from another class

I am working on a problem and I am very stuck because I am just starting to learn java. Any help I can get to understand this would be great. I have to write a program that has two classes. The main class will read from a file and uses the second class to find how may times the same words have been repeated in the file and add them to an array that contans the words and number of times the word repeated. I am ok with the reading the file part. I just can't seem to wrap my head around how to call a method from the second class to add the word into the array and increment the counter. Here is my code so far if you run it you will see how new I am to this by how many errors you will get.

import java.io.*;

public class Words{
public static void main (String [] args)
{
    ProcessInput();
    System.out.println("\nprogram finished");
}


public static WordList ProcessInput( )
{
    BufferedReader inputFile;
    String inputLine;
    String[] word;
    WordList words;
        try
        {
            inputFile=new BufferedReader(new FileReader ("inputFile.txt"));
            inputLine = inputFile.readLine();
            while (inputLine !=null)
            {
                word=inputLine.toLowerCase().split(" ");
                for (int i=0; i<word.length; i++){
                    System.out.println (word[i]);
                    words=addWord(word[i]);
                }
                inputLine = inputFile.readLine();

            }
            inputFile.close();
        }
        catch (IOException ioe)
        {
            System.out.println (ioe.getMessage());
            ioe.printStackTrace ();
        }
        return words;
}

}

class WordList {
String [] words;
int wordcount;
public WordList ( ){
    words= new String [1000];
    wordcount=0;

}

public String  addWord (String word) {
    words[wordcount]=word;
    wordcount=+1;
    return words[wordcount];

}

public void printList (){
    for (int i=0; i<wordcount; i++){
        System.out.println (words[i]);
    }
}
}

This question is related to java

The answer is


You have to initialise the object (create the object itself) in order to be able to call its methods otherwise you would get a NullPointerException.

WordList words = new WordList();