• Post Reply Bookmark Topic Watch Topic
  • New Topic

enum  RSS feed

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I have problem with this line

enumtest.Foo test=BA2;
System.out.print(test);
How can I fix this?

It does not print anything!!!
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, your code does not even compile.
First, remove those */ from lines 1 and 11.
Second, your line 20 should be enumtest.Foo test= enumtest.Foo.BA2;
And then it prints fine.

And of course classes enumtest and Enumquestion should be in separate files because they are both public.
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:Well, your code does not even compile.
First, remove those */ from lines 1 and 11.
Second, your line 20 should be enumtest.Foo test= enumtest.Foo.BA2;
And then it prints fine.

And of course classes enumtest and Enumquestion should be in separate files because they are both public.


This line:

Means:

test is a a variable. Its type is Foo enum from enumtest class.Right?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abalfazl hossein wrote:test is a a variable. Its type is Foo enum from enumtest class.Right?

Yes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!