Q:

How to access input variable from another class? java

Trying to get the 1st class to recognize what the user inputs in the 2nd class. Any ideas as to what is going wrong here? The 2nd class works fine, but when i try to call 'input' from the main class, it says that 'input' cannot be resolved. Any suggestions and pointers much appreciated. Thanks for your time.
1st class:
public class Filter {

   public static void main(String[] args) throws IOException { 
      BufferedReader in4 = new BufferedReader(new StringReader(automata.input));

      String s = input.readLine();
      while (automata.UserInput()==true){
         if (automata.accepts(s)) System.out.println(s); 
         s = input.readLine();
      }
   }
}

2nd class:
public class automata extends Filter {

public static String input;
public static boolean UserInput() {

    System.out.println("Please enter test data: ");
    Scanner user_input = new Scanner(System.in);
    input = user_input.next();

    if (accepts(input) == true){
         System.out.print("works");
         return true;
     } else { 
       System.out.println("Problem");
       return false;
     }
}

A:

2nd class should look like:
public class Automata { // we use upper case for class names

   public String input; // or better private and use a get-method

   public Automata() {} // constructor

   public boolean readUserInput() { // lower case here
        System.out.println("Please enter test data: ");
        Scanner user_input = new Scanner(System.in);
        String nextInput = user_input.next();
        input += nextInput; // otherwise you overwrite your current input
        /*if (accepts(input) == true){
            System.out.print("works");
            // return true;
        } else { 
            System.out.println("Problem");
            return false;
        }*/
        // It is a terrible idea to return every time a single word is read
        // rather read the whole String and then check if it is accepted
        if (accept(input)) // whole String is checked
            return true;
        return false;
    }
    // in case the input variable is private
    public String getInput() {
         return input;
    }
}

And then you have to access the class in this way:
public class Filter {

      public static void main(String[] args) throws IOException { 
           Automata automata = new Automata();
           if (automata.readUserInput()) {
                // BufferedReader in4 = new BufferedReader(new StringReader(automata.getInput())); or automata.input in case it is public
                // I don't understand why you want to read the input here again step by step
                // rather read the whole input here
                String userInput = automata.getInput();
           }
      }
 }

