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

Started by
3 comments, last by Enerjak 11 years, 5 months ago
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.
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() {
// ...
}
}

/*
* 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
}
}
[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]
thanks alot.

This topic is closed to new replies.

Advertisement