I'm trying to create a program in which the first step is for the user to input their name (in the User class). I wanted to create a method (in another class) that specifically reads the input and then implement that method in my User class.
However, I'm getting a NullPointerException error and I don't quite understand why.
 public class Main {
     public static void main(String[] args) {
         User newUser=new User();
         newUser.CreateName(); 
     }
 }
 public class User {
     UserInput ui;
     public void CreateName(){
         System.out.println("Enter your name:");
         String name= ui.Input();
     }
 }
 public class UserInput {
     public String Input(){
         Scanner input=new Scanner(System.in);
         String s=input.nextLine();
         return s;
     }
 }
 
     
    