There is a Person class, I have to pass it to the PersonStatus class so that it contains all the fields of the Person class and so I can add new fields that relate only to the PersonStatus class.

I suggested that you can do so:

 class Person{} class PersonStatus{ PersonStatus pst = new PersonStatus(Person); } 

But it swears

"Person cannot be resolved"

    3 answers 3

    You call the constructor of the class PersonStatus , which is not declared.

    Announce it:

     PersonStatus(Person person) { // Ваши манипуляции с переданным экземпляром класса Person } 

    And in the main program, use this constructor:

     Person somePerson = new Person(); // Устанавливаете поля somePerson PersonStatus personStatus = new PersonStatus(somePerson); 

      Judging by the terminology you use (class ... pass to class ...) you need to start from the beginning. In this case, it is necessary to transfer not a class, but a value, and not to a class, but to a method.

        Do you need to pass one class to another class? So:

         public Person { ... } public PersonStatus { private Person person; public PersonStatus(Person p) { this.person = p; } } 

        Or to create a class in which there would be all fields, methods, .. another class? Then this inheritance:

         public PersonStatus extends Person { public void AnyMethod() { // тут доступны все public и protected поля, методы,... класса Person } } 
        • 3
          public class PersonStatus extends Person , this is true hard. - Costantino Rupert
        • Oh, exactly - this is how it is done in java! :) - Yak SD