Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

an enum switch case label must be the unqualified name of an enumeration constant

 
Ronwaldo Cruz
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm new to Java 5

Could somebody take a look at why there's a compiler error?

public class SLAComputer {

/** Creates a new instance of SLAComputer */
public SLAComputer() {
}

public static void main(String[] args) {

SLAComputer computer = new SLAComputer();

Ticket ticket = new Ticket(Ticket.Priority.ONE, new Date());

}

public Date computeSLA(Ticket ticket) {

Ticket.Priority priority = ticket.priority;
Date date = new Date();

switch(priority) {

case(Ticket.Priority.ONE): //do something with the date

}

return date;


}

}

class Ticket {

public enum Priority { ONE, TWO, THREE, FOUR }
public enum Day { BUSINESS, CALENDAR }

Priority priority;
Date loggedDAte;

Ticket(Priority priority, Date loggedDate) {

this.priority = priority;
this.loggedDAte = loggedDate;

}

}

The compiler says: "an enum switch case label must be the unqualified name of an enumeration constant"

Could somebody please help with this?

Thanks
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15485
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message means that you have to use this:

case ONE:

instead of "case(Ticket.Priority.ONE):".
 
Ronwaldo Cruz
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. This helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic