• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enums in java

 
Rupali Desai
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Taking reference from the book I created enums in java as follows
:
public class ACGOutputType
{
private final String type;
//public final static ACGOuputType XMLType = null;
//public final static ACGOuputType HTMLType = null;
//public final static ACGOuputType proxyType = null;

private ACGOutputType(String type)
{
this.type = type;
}
public final static ACGOutputType XMLType = new ACGOutputType("outputAsXML");
public final static ACGOutputType HTMLType = new ACGOutputType("outputAsHtml");
public final static ACGOutputType proxyType = new ACGOutputType("outputAsProxy");

public String toString()
{
return this.type;
}
public static void main(String args[])
{
System.out.println("Hello World");
System.out.println(ACGOutputType.XMLType);
}
}

When i am trying to use them as follows
if(type == ACGOutputType.HTMLType)
{
}
....
I get following error
.\ACG.java:143: int cannot be dereferenced
if(type == ACGOutputType.HTMLType)
where type is ACGOutputType.XMLType;
Could someone explain why I am getting this compile time error
Thanks
Rupali Desai
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you previously define ACGOutputType.HTMLType as an int? Is it possible the old .class file is still around, and has not been recompiled? Try deleting all .class files, and compile everything again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic