Re: enum type declaration error



akarui.tomodachi@xxxxxxxxx wrote:
I came from C domain and learning JAVA.
I believe, there is C equivalent "enum" type existed in JAVA. But my
initial experiment is giving compile error as below. Please help me to
understand where I made mistake. Note that, I am using the latest GCC
compiler for JAVA (gcj).

Thanks in advance.

Compile error:
/*****
myHelloWorld.java:8: error: Invalid declaration.
public enum returnStatus {RETURN_TRUE, RETURN_FALSE}
^
myHelloWorld.java:8: confused by earlier errors, bailing out

*****/


My experimental code is as below:
/*
myHelloWorld.java
*/
public class myHelloWorld
{

// Return value definition (public)
public enum returnStatus {RETURN_TRUE, RETURN_FALSE}

// Private method to print something on the console
private returnStatus printSomething()
{
// Return status intialization
returnStatus retValue = new returnStatus;

// Print something on the console
System.out.println("Hi Hello World !");

//Return
retValue = retValue.RETURN_TRUE;
return retValue;

}//printSomething()

// Main method
public static void main(String[] args)
{
printSomething();
}//main()
}//myHelloWorld class


1 - Code Conventions for the Java Programming Language
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html

2 - Enums 1.5.0
http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html

--
Thanks in Advance... http://ichbin.9999mb.com
IchBin, Pocono Lake, Pa, USA
______________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
.



Relevant Pages

  • Re: enum type declaration error
    ... there is C equivalent "enum" type existed in JAVA. ... initial experiment is giving compile error as below. ... public enum returnStatus ...
    (comp.lang.java.programmer)
  • enum type declaration error
    ... there is C equivalent "enum" type existed in JAVA. ... initial experiment is giving compile error as below. ... public enum returnStatus ... returnStatus retValue = new returnStatus; ...
    (comp.lang.java.programmer)
  • Re: enum type declaration error
    ... is the code missing a; after the enum declaration line? ... there is C equivalent "enum" type existed in JAVA. ... initial experiment is giving compile error as below. ... public enum returnStatus ...
    (comp.lang.java.programmer)
  • Re: C2664 compilation error by using typedef enum in a idl file
    ... are reserved for the compiler vendors. ... Unfortunatly the compile error didn't changed. ... Did you put the enum outside any other block, even outside the library block? ...
    (microsoft.public.vc.atl)
  • enum handling change in VS 2005
    ... I've installed the VS 2005 Beta 1 and was trying to build our current ... I get a compile error when enum value is specified with ... class CMyEnumClass ... enum MyMode ...
    (microsoft.public.dotnet.languages.vc)