package com.codegym.task.task05.task0503;
/*
Getters and setters for the Dog class
*/
public class Dog {
//write your code here
public String name;
public int age;
public String getName()
{ return name; }
public String setName(String name)
{ this.name = name; }
public void getAge()
{
return age;
}
public void setAge(int age)
{ this.age = age; }
public static void main(String[] args) {
}
}
why it is showing error
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Vatsal Patel
7 February 2019, 22:50
What others have said
0
Swati
14 January 2019, 04:28
As the get method returns some value,so it should not have void as return type and set method does not returns value,so it should have return type has void..
0
Hashirama
13 January 2019, 15:55
The setter method does not return any value.
However, this is not the case for the getter method: the getter method returns a value.
That's where your error is. Check the return types
+1