473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need help with enums in java 1.5

I am trying to compile the following java code with the beta version
of java 1.5.
import java.*;

public class hello {

public enum test { a, b, c, d, e };
public static void main(String[] args){
System.out.println("hello world");

}
}

I get the following error:

$ javac hello.java
hello.java:5: warning: as of release 1.5, 'enum' is a keyword, and may not be us
ed as an identifier
public enum test { a, b, c, d, e };
^
hello.java:5: ';' expected
public enum test { a, b, c, d, e };
^
1 error
1 warning

Am is missing something ?
Thanks
Jul 17 '05 #1
2 5480

"Parag" <dv***@routepulse.com> wrote in message
news:38**************************@posting.google.c om...
I am trying to compile the following java code with the beta version
of java 1.5.
import java.*;

public class hello {

public enum test { a, b, c, d, e };
public static void main(String[] args){
System.out.println("hello world");

}
}

I get the following error:

$ javac hello.java
hello.java:5: warning: as of release 1.5, 'enum' is a keyword, and may not be us ed as an identifier
public enum test { a, b, c, d, e };
^
hello.java:5: ';' expected
public enum test { a, b, c, d, e };
^
1 error
1 warning

Am is missing something ?
Thanks


Yes, you are missing the -source 1.5 directive to your compiler.

Silvio Bierman
Jul 17 '05 #2
Thanks, that did the trick.

"Silvio Bierman" <sb******@idfix.nl> wrote in message news:<40***********************@news.xs4all.nl>...
"Parag" <dv***@routepulse.com> wrote in message
news:38**************************@posting.google.c om...
I am trying to compile the following java code with the beta version
of java 1.5.
import java.*;

public class hello {

public enum test { a, b, c, d, e };
public static void main(String[] args){
System.out.println("hello world");

}
}

I get the following error:

$ javac hello.java
hello.java:5: warning: as of release 1.5, 'enum' is a keyword, and may not

be us
ed as an identifier
public enum test { a, b, c, d, e };
^
hello.java:5: ';' expected
public enum test { a, b, c, d, e };
^
1 error
1 warning

Am is missing something ?
Thanks


Yes, you are missing the -source 1.5 directive to your compiler.

Silvio Bierman

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jochen Daum | last post by:
Hi, I have to emulate a "file upload" to a Java Servlet which is done with the class URLConnection. The java source basically does URLConnection conn =...
13
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could...
1
by: Hexar Anderson | last post by:
Why can't you pin an enumeration? For example, the with the following code: public enum MyEnum : byte { ValueOne = 1, ValueTwo = 2 } public class MyClass {
2
by: David Veeneman | last post by:
I want to data bind a user control and a business object, using a BindingSource control. The control has a 'Priority' property that takes a 'Priority' enum (High, Normal, Low). The business object...
3
by: Stefan Mueller | last post by:
Because the characters ', ", ... make troubles in my input boxes I use the following PHP command while generating the page htmlentities($my_var, ENT_QUOTES); However, if I use in my java scripts...
6
by: Stefan Mueller | last post by:
I read data (e.g. äöüÄÖÜçéàè"') from my MySQL database which I'd like to show in an input box. <?php $mysql_data = "äöüÄÖÜçéàè\"'"; $html_data = addslashes(htmlentities($mysql_data,...
4
by: nomad | last post by:
Hi, I would like to create a enum which consists of contenttype i.e. text/ xml and application/x-www-form-urlencoded. Would this be possible? Appreciate any suggestions.
13
by: falconsx23 | last post by:
Hi, I need help with my java program. I am new with java, so go easy on me if this is a dumb question. Ok the question is "You will complete two methods for this exercise. The headers (and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.