Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<identifier> expected compile error

Tags:

java

android

I am trying to figure out why I get a compile error on the code below:

package com....;
public enum Something { //says error: <identifier> expected on this line

private String myInput;

public Something(String paramString) {
    this.myInput = paramString;
}

public String getInputName() {
    return this.myInput;
}
}
like image 880
michaelsmith Avatar asked Mar 17 '23 05:03

michaelsmith


2 Answers

You have couple of problem with your enum declaration , first enum constructor cannot be public and second you need to add ; before private field. E.g.

public enum Something {
    ;
    private String myInput;

    Something(String paramString) {
        this.myInput = paramString;
    }

    public String getInputName() {
        return this.myInput;
    }
}
like image 68
sol4me Avatar answered Mar 18 '23 18:03

sol4me


Since it seems you are not using enumerations, change "enum" to "class".

package com....;
public class Something {

    private String myInput;

    public Something(String paramString) {
        this.myInput = paramString;
    }

    public String getInputName() {
        return this.myInput;
    }
}
like image 40
Zigac Avatar answered Mar 18 '23 20:03

Zigac