'How do I call one constructor's variable into another constructor variable?

I saw several posts based on calling variables of one constructor to another. But I am beginner using visual studio to code, we are not using any "main" method. In my case, we just call a class and the terminal spits out all the information of the method created.

class ExampleTweets {

    String username1 = "UCSD Engineering";
    String diplayName1 = "UCSDJacobs";
    int followers1 = 13100; 

    User u1 = new User(diplayName, username1, followers1);

    String tweet1 = "And last but not least, also from @arcucsd: Pose Estimation for Robot Manipulators via Keypoint Optimization and Sim-to-Real Transfer: https://arxiv.org/pdf/2010.08054.pdf"
    
    Tweet t1 = new Tweet(tweet1, u1.username, 1, "1514286318947213312");

}

class Tweet {
    String content;
    String username;
    int likes;
    String userID;

    Tweet(String content,String username,int likes,String userID) {
        this.content = content;
        this.username = username;
        this.likes = likes;
        this.userID = userID;
    }
}

class User {
        String username;
        String displayName;
        int followers;

    User(String displayName, String username, int followers) {
        this.username = username;
        this.displayName = displayName;
        this.followers = followers;
    }
}

Output -

    new ExampleTweets:1(
 this.u1 = new User:2(
  this.username = "UCSDJacobs"
  this.displayName = "UCSD Engineering"
  this.followers = 13100
  this.textEx1 = "POTUS @Joe Biden"
  this.textEx2 = "Canelo Alvarez @Canelo")
 this.t1 = new Tweet:3(
  this.content = "And last but not least, also from @arcucsd: Pose Estimation for Robot Manipulators via Keypoint Optimization and Sim-to-Real Transfer: https://arxiv.org/pdf/2010.08054.pdf"
  this.username = User:2 //problem :/
  this.likes = 1
  this.userID = "1514286318947213312")
 this.t2 = new Tweet:4(
  this.content = "Look Closer: Bridging Egocentric and Third-person Views with Transformers for Robotic Manipulation: senior author @xiaolonw: https://arxiv.org/pdf/2201.07779.pdf"
  this.username = User:2
  this.likes = 1
  this.userID = "1514286318947213312")

If you see this.username, I think it's just printing the location of the variable. How to fix it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source