I don’t know what you want to do, but this is how I actually translated your example code….
package test; /** * @author The Elite Gentleman * */ public enum Strings { STRING_ONE("ONE"), STRING_TWO("TWO") ; private final String text; /** * @param text */ Strings(final String text) { this.text = text; } /* (non-Javadoc) * @see java.lang.Enum#toString() */ @Override public String toString() { return text; } }
Alternatively, you can create a getter method for text
.
You can now do Strings.STRING_ONE.toString();
Related Posts:
- How to get an enum value from a string value in Java
- Java: using switch statement with enum under subclass
- Using Enum values as String literals
- Java Enum return Int
- Coding Conventions – Naming Enums
- Java using enum with switch statement
- Implementing UML diagram to Java [closed]
- Reading a plain text file in Java
- Converting double to string
- What is the “continue” keyword and how does it work in Java?
- Java String new line
- What does the protected modifier mean?
- Java default constructor
- What is the meaning of “this” in Java?
- ‘Java’ is not recognized as an internal or external command
- Java: Identifier expected
- How does Java’s PriorityQueue differ from a min-heap?
- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Eclipse
- Java split string to array [duplicate]
- Reason for”Exception in thread “AWT-EventQueue-0″ java.lang.NullPointerException”
- How to split a String by space
- Java compile error: “reached end of file while parsing }”
- How to create a sub array from another array in Java?
- Double % formatting question for printf in Java
- in java what does the @ symbol mean?
- How to call a method in another class in Java?
- unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- Java, “Variable name” cannot be resolved to a variable
- How to convert a Binary String to a base 10 integer in Java
- Java Method Stubs
- Received fatal alert: handshake_failure through SSLHandshakeException
- DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704
- Why would a “java.net.ConnectException: Connection timed out” exception occur when URL is up?
- HashSet vs. ArrayList
- FIFO based Queue implementations?
- How to import a .cer certificate into a java keystore?
- Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0 error in Java
- How can I represent a range in Java?
- How to solve error: ‘;’ expected in Java?
- Making a Java Makefile
- Censored Words Condition
- method in class cannot be applied to given types
- unused import statement for used ones in IntelliJ IDEA
- Unsigned long in Java
- Android java.lang.IllegalStateException: Could not execute method of the activity
- Java error: Comparison method violates its general contract
- “Cannot create generic array of ..” – how to create an Array of Map
? - javac: file not found: first.java Usage: javac
- Eclipse Java error: This selection cannot be launched and there are no recent launches
- align text center with android
- hat is the purpose of flush() in Java streams?
- How can I convert integer into float in Java?
- How can I avoid this Ant Build error?
- Java Comparator class to sort arrays
- (The Triangle class) Design a class named Triangle that extends GeometricObject
- Cannot assign requested address using ServerSocket.socketBind
- Consider defining a bean of type ‘package’ in your configuration [Spring-Boot]
- Java – How to do floor division?
- Short form for Java if statement
- How to read json file into java with simple JSON library
- How can I convert a long to int in Java?
- org.apache.jasper.JasperException: Unable to compile class for JSP:
- How do I parse command line arguments in Java?
- Eclipse java debugging: source not found
- IntelliJ – Can’t start – “JAVA_HOME does not point to a valid JVM installation”
- Empty an array in Java / processing
- Class is not Abstract and does not Override error in Java
- hibernate properties not found
- Make a simple timer in Java
- How to switch scenes in JavaFX
- Corrupt jar file
- Replace a character at a specific index in a string?
- Error array dimension missing
- How to detect EOF in Java?
- Information about _JAVA_OPTIONS
- Two dimensional array list
- Must issue a STARTTLS command first
- Convert boolean to int in Java
- How to convert a String to CharSequence?
- Aspect Ratio with 800×480
- How do I convert a String to a BigInteger?
- How to set JAVA_HOME in Linux for all users
- What is ‘PermSize’ in Java?
- Big Oh for (n log n)
- Eclipse: JVM terminated. Exit code=2
- How to programmatically close a JFrame
- Playing .mp3 and .wav in Java?
- Difference between jar and war in Java
- Adding image to JFrame
- Java Fraction Calculator
- How to convert a date to milliseconds
- Eclipse IDE – Error: Build path specifies execution environment Java SE 1.7
- How do I join two lists in Java?
- How to insert multiple tabs string in java?
- Java methods getting euclidean distance
- Troubleshooting “The type parameter T is hiding the type T” warning
- model.addAttribute() parameters
- StringFormat for Java Boolean Operator
- JOptionPane Yes or No window