• Advertisement
Sign in to follow this  

trouble making an enum in java (weird error(s))

This topic is 1911 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

as you can tell from the title, i'm having a little trouble currently creating an enum in java as it gives weird errors such as:

http://puu.sh/1kuOn

not sure if you want the code also as it's right there in the image let me know.

Share this post


Link to post
Share on other sites
Advertisement
Please post the code. If you want to add fields, constructors or methods to a Java enumeration, you must end the list of enum names with a semicolon:

public enum Suit {
Hearts,
Spades,
Clubs,
Diamonds; // <-- Semicolon here indicates end of suits!

@Override
public String toString() {
// ...
}
}

Share this post


Link to post
Share on other sites

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
/**
*
* @author lucifir
*/
public class JavaApplication1 {
enum Suit
{
private final String colName;

private Suit(String name)
{
colName = name;
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}

Share this post


Link to post
Share on other sites
[source lang="java"]package javaapplication1;

public class JavaApplication1 {

enum Suit {
HEARTS("Hearts"),
SPADES("Spades"),
CLUBS("Clubs"),
DIAMONDS("Diamonds");

private final String colName;

private Suit(String name) {
colName = name;
}

}

public static void main(String[] args) {
// TODO code application logic here
}

}[/source] Edited by ppgamedev

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement