+ 1

I have an error on printDetail method

public class person { private String name; private int age; public person(String myName, int myAge) { name = myName; age = myAge; } public String getName()//1 { return name; } public int getAge() { return age; } public void setage(int age)//2 { this.age = age; } public void setName(String name) { this.name = name; } public void printDetails(String name) { System.out.println("the name of the person is: ","+name"); } public static void main(String[] args){ person p = new person("ali",12); } }

16th Aug 2020, 12:29 PM
abdullah
7 Answers
+ 1
System.out.println("the name of the person is: " + name); Your print statement should look like this. I just changed it ans compiled the code. Got no error. 😊
17th Aug 2020, 7:41 AM
Mirko Dreher
Mirko Dreher - avatar
+ 1
abdullah for print statement, Proper way : System.out.println("the name of the person is: "+name); May you don't put full code.. Save code in playground and share link here.. That help you find answer quickly.. https://www.sololearn.com/post/75089/?ref=app
16th Aug 2020, 12:50 PM
Jayakrishna 🇼🇳
+ 1
Just remove the parantheses before and after + name.
16th Aug 2020, 2:24 PM
Mirko Dreher
Mirko Dreher - avatar
0
I remove but the error was still not remove
17th Aug 2020, 3:46 AM
abdullah
0
Hmm
17th Aug 2020, 8:12 AM
abdullah
0
Ok thank you
17th Aug 2020, 8:12 AM
abdullah
0
The error was because i wrote " , " before +name
18th Aug 2020, 3:40 AM
abdullah