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 trialPascal Petruch
1,479 Pointsformal parameters don't match when defining enum
Hello everyone,
the compiler says that the formal parameters don't match. There seems to be a problem with the line 4: JCV, SONY, COBY, APPLE;
I can't figure out why. Does anybody know where I made an error?
Kind regards, Pascal
package com.example.model;
public enum Brand{
JCV, SONY, COBY, APPLE;
private String displayName;
Brand(String displayName) {
this.displayName = displayName;
}
public String getDisplayName() {
return displayName;
}
}
1 Answer
Joseph Wasden
20,406 PointsThe problem is that your ENUMS need to take a parameter. If you look at the constructor your created, it alters the property displayName using the argument passed into the constructor. In the code below, I've passed in an argument of the lowercase spelling for each brand of radio.
see the following example.
package com.example.model;
public enum Brand{
JVC("JVC"), //corrected spelling
SONY("Sony"),
COBY("Coby"),
APPLE("Apple");
private String displayName;
Brand(String displayName) {
this.displayName = displayName;
}
public String getDisplayName() {
return displayName;
}
}