I'm trying to assign a value to a variable in another class using input from the user. My goal is to use the "fullName" setter value that was called in the secondary class but I keep getting the error "cannot resolve symbol fullName". I think it may be because the variable in the other class is private, but I edited the visibility to public and that didn't change anything. How can I do this?
Here's my code:
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter your full name:\n");
fullName = scan.nextLine();
}
}
// Secondary class
public class Person {
private int id;
private String fullName;
// Constructor
public Person(String fullName, String id){
}
// Setters
public static void setName(String fullName){
this.fullName = fullName;
}
public static void setid(int id){
this.id = id;
}
//getters
public String getfullName(){
return fullName;
}
public int getid(){
return id;
}