Click here to Skip to main content
15,905,914 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how can i change public to private class for the FacultyId
public class Faculty  {
   public int FacultyId;
   public String surname1;
   public String lastName1;
   public int age1;

  
   public Faculty(int FacultyId1, String surname1, String lastName1, int age1) {
       this.FacultyId = FacultyId;
       this.surname1 = surname1;
       this.lastName1 = lastName1;
       this.age1 = age1;

   }

   public int getFacultyId() {
       return FacultyId;
   }

   public void setFacultyId(int FacultyId) {
       this.FacultyId = FacultyId;
   }

   public String getSurname() {
       return surname1;
   }

   public void setSurname(String surname) {
       this.surname1 = surname;
   }

   public String getLastName() {
       return lastName1;
   }

   public void setLastName(String lastName1) {
       this.lastName1 = lastName1;
   }

   public int getAge() {
       return age1;
   }

   public void setAge(int age1) {
       this.age1 = age1;
   }



}


What I have tried:

public class Faculty  {
   private int FacultyId;
   public String surname1;
   public String lastName1;
   public int age1;

  
   public Faculty(int FacultyId1, String surname1, String lastName1, int age1) {
       this.FacultyId = FacultyId;
       this.surname1 = surname1;
       this.lastName1 = lastName1;
       this.age1 = age1;

   }

   public int getFacultyId() {
       return FacultyId;
   }

   public void setFacultyId(int FacultyId) {
       this.FacultyId = FacultyId;
   }

   public String getSurname() {
       return surname1;
   }

   public void setSurname(String surname) {
       this.surname1 = surname;
   }

   public String getLastName() {
       return lastName1;
   }

   public void setLastName(String lastName1) {
       this.lastName1 = lastName1;
   }

   public int getAge() {
       return age1;
   }

   public void setAge(int age1) {
       this.age1 = age1;
   }



}
Posted
Updated 26-Apr-21 10:03am
Comments
Richard MacCutchan 26-Apr-21 16:10pm    
What do you mean? You only have a single class (Faculty), and if you make it private then no other class will be able to access it.

1 solution

If I'm looking this correctly, you have misspelled the parameter in constructor. It probably should be FacultyId1

Java
public Faculty(int FacultyId1, String surname1, String lastName1, int age1) {
       this.FacultyId = FacultyId1;
       this.surname1 = surname1;
       this.lastName1 = lastName1;
       this.age1 = age1;
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900