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)
![Awais Jamil](https://uploads.teamtreehouse.com/production/profile-photos/7663282/micro_my_Picture1.jpg)
Awais Jamil
7,539 PointsCannot Solve this Excersice
Please Help i am not Sure how to you Override this Method.
public class HelloWorld {
private String programmingLanguage;
public HelloWorld() {
programmingLanguage = "Java";
}
@Override
public void sayHelloTo(String name) {
HolaWorld obj = new HolaWorld();
obj.sayHelloTO();
System.out.printf("Hello, %s%n!", name);
}
}
public class HolaWorld extends HelloWorld {
@Override
public void sayHelloTo(String name) {
String name = "";
return System.out.printf("Hola, %s%n!", name);
}
}
2 Answers
![doesitmatter](https://uploads.teamtreehouse.com/production/profile-photos/5089972/micro_20091116_030905000_iOS.jpg)
doesitmatter
12,885 PointsHi Awais Jamil,
@Override
public void sayHelloTo(String name) {
//sets name to "" meaning we remove the value we are supposed to print... not good
String name = "";
//This gives an error, because System.out.printf() is a VOID method, it doesnt return anything.. This method itself is also void, it isn't supposed to return anything
return System.out.printf("Hola, %s%n!", name);
}
Notice that even if you don't return System.out.printf but just run it, your method now always returns Hola without a name. Is String name = "";
really necessary?
Good luck!
![Cameron Jones](https://uploads.teamtreehouse.com/production/profile-photos/5502252/micro_D96ED913-F2D0-4680-9649-6A27479764C7.jpg)
Cameron Jones
10,049 PointsUsing the @Override method the compiler will check if it's correct with the parent class. However, the compiler throws an error, because the new method trying to Override the parent is missing its parameters, and it attempts to create an unnecessary name.