I'm new to java and I'm creating generic social media site. My user class has the ability to create a "Post" class. When attempting to view these post I receive the aforementioned error. I'd like to make a method within the class so that the user class and view it's the string associated with it's post class.
   import java.util.Scanner;
public class User {
  private String password, address;
  private Post myPost;
  private int age;
  public String userName;
public User (String u, String p, String l, int a) {
   userName = u;
   password = p;
   address = l;
   age = a;
}
  public String viewLoginName ( ) {
    return userName;
  }
  public String viewPassword ( ) {
    return password;
  }
  public String viewAddress ( ) {
    return address;
  }
  public int viewAge ( ) {
    return age;
  }
  public Post createPost ( ) {
    Scanner reader = new Scanner ( System.in );
    String message;
    System.out.println("What would you like to share? ");
    message = reader.next ( );
    myPost = new Post(userName + ": " + message);
    return myPost;
  }
  public String viewMyPost()
   { 
     return myPost.viewPost();
  }
//the new method meant to allow users to view other users post
 public String viewUserPost(String user)
     {
      return user.viewMyPost();
     } 
}
//Post Class
import java.util.Scanner;
public class Post {
    private String message, acknowledged = "";
    //Scanner reader = new Scanner ( System.in );
    //message = reader.nextString ( );
    public Post(String m) {
        message = m;
    }
    public String viewPost() {
        return message;
    }
    public String acknowledge() {
        System.out.println("What is your username?");
        Scanner reader = new Scanner(System. in );
        String acknowledger;
        acknowledger = reader.next();
        acknowledged = acknowledged + acknowledger + ',';
        return acknowledged;
    }
}
 
    