Ashley P.

asked • 07/20/20

Java Programming - Unclosed Literal

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();



}



}

1 Expert Answer

By:

Zachary A. answered • 07/20/20

Tutor
5 (26)

A passionate computer science tutor with industry experience!

Ashley P.

Thank you very much for the explanation!
Report

07/20/20

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.