For the following code I'm getting an error message saying :
test.java:78: error: unclosed character literal
Person p = new Person(1, "G", 12,'female');
^
What could be the reason, since I don't have an unclosed literal there?
code :
class Person{
private int id;
private String name;
private int age;
private char gender;
//constructor for Person class
public Person(int id, String name, int age, char gender){
this.id = id;
this.name = name;
this.age = age;
this.gender = gender;
}
//getter & setters for attributes of Person class
public void setId(int id){
this.id = id;
}
public int getId(int id){
return id;
}
public void setName(String name){
this.name = name;
}
public String getName(String name){
return name;
}
public void setAge(String name){
this.age = age;
}
public int getAge(int age){
return age;
}
public void setGender(String name){
this.gender = gender;
}
public char getGender(char gender){
return gender;
}
public void display(){
System.out.println(id);
System.out.println(name);
System.out.println(age);
System.out.println(gender);
}
}
class test{
public static void main(String[] args){
Person p = new Person(1, "G", 12, 'female');
p.display();
}
}
Ashley P.
Thank you very much for the explanation!07/20/20