Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Enums and diffrent classes  RSS feed

 
Chadd Franck
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a legal declaraition?

PlayerOne is an Object that extends LifeformTemplate
and has a public method called getStat(StatsEnum m)
that returns an Integer and a public enum in the LifeformTemplate class called StatsEnum {STR, CON};



Thanks
 
Campbell Ritchie
Marshal
Posts: 54882
155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just at a � second look, it looks all right. You are passing a String to a JTextField constructor, which should be OK. You will have to try it to confirm that it shows what you actually want . . .
 
Chadd Franck
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it did end up being valid, I had some problem elsewhere in my code, I figured it out but don't remember what it was. It was my first time time using enums and I wasn't sure you could access them from another class' method.
 
I child proofed my house but they still get in. Distract them with this tiny ad:
Thoughts on deprecation in Java
https://coderanch.com/t/683016/java/Deprecation-Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!