Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Kulvir Bajwa](https://secure.gravatar.com/avatar/b16615b8f8fc81d4867682628d3eaeab?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Kulvir Bajwa
1,232 PointsWhen using the @Override annotation, is it only the method signatures, return type and parameters that need to match?
Can't seem to get passed this @Override annotation exercise. I've checked that the method signature, return type and parameters match but it still won't accept it. Any ideas?
public class HelloWorld {
private String programmingLanguage;
public HelloWorld() {
programmingLanguage = "Java";
}
public void sayHelloTo(String name) {
System.out.printf("Hello, %s%n!", name);
}
}
public class HolaWorld extends HelloWorld {
@Override
public void sayHelloTo(String name) {
String name = "";
System.out.printf("Hola, %s%n!", name);
}
}
2 Answers
![andren](https://secure.gravatar.com/avatar/229e60726cd92951c31d7303e40be2cd?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
andren
28,558 PointsYou are overriding the method correctly, that's not what is producing the compiler error.
Whenever you get a compiler error your first response should always be to look at the actual error message the compiler has produced. Compiler errors are often quite explicit about what is wrong in your code. The error message your code generates is this:
./HolaWorld.java:4: error: variable name is already defined in method sayHelloTo(String)
String name = "";
^
1 error
You are getting a compiler error because the first thing the overridden sayHelloTo method does is declare a "name" variable even though it already has a "name" variable declared in its parameter list.
If you remove the line the compiler is pointing out, you'll be able to pass the challenge.
![Sagar Thakkar](https://secure.gravatar.com/avatar/851c5f27055397b1f51abb01704aaacc?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Sagar Thakkar
8,814 Pointsjust remove "String name = """ from HolaWorld class it will work.....