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

Java Build a JavaFX Application Build a Pomodoro App Enums

Enums

./com/example/model/Brand.java:5: error: constructor Brand in enum Brand cannot be applied to given types; JVC, ^ required: String found: no arguments reason: actual and formal argument lists differ in length ./com/example/model/Brand.java:6: error: constructor Brand in enum Brand cannot be applied to given types; SONY, ^ required: String found: no arguments reason: actual and formal argument lists differ in length ./com/example/model/Brand.java:7: error: constructor Brand in enum Brand cannot be applied to given types; COBY, ^ required: String found: no arguments reason: actual and formal argument lists differ in length ./com/example/model/Brand.java:8: error: constructor Brand in enum Brand cannot be applied to given types; APPLE; ^ required: String found: no arguments reason: actual and formal argument lists differ in length 4 errors

Can someone help me sort out the problem?

com/example/model/Brand.java
package com.example.model;

public enum Brand {
  // Your code here 
  JVC,
  SONY,
  COBY,
  APPLE;

  private String mDisplayName;

  Brand(String displayName) {
    mDisplayName = displayName;
  }

  public String getDisplayName() {
    return mDisplayName;
  }


}

2 Answers

Simon Coates
Simon Coates
28,694 Points

you need to pass the arguments through to the constructor.

package com.example.model;

public enum Brand {

    JVC("JVC"),
  SONY("Sony"),
  COBY("Coby"),
  APPLE("Apple");

    private String mDisplayName;

  Brand(String displayName) {
    mDisplayName = displayName;
  }

  public String getDisplayName() {
    return mDisplayName;
  }
}

(i'd assume that the presence of a constructor means that the default no arg constructor isn't created. If you added a no arg constructor, then the code would be valid from java's perspective, but not satisfy the task instructions)

I see what you're saying. Thanks.

Martin Gallauner
Martin Gallauner
10,808 Points

Hi

I miss the point in the video when Craig explains how to use a argument with the enum?

E.g APPLE ("Apple");