This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

public static final int in javafx

 
Fabricio Sanchez
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I can't find a way in javafx to use public static final int variables.
Can anyone tell me the official way to do this (or a work around)?

Example in java:


javaFx attempted code:


However the above doesn't work. I'm guessing because maybe I'm trying to access a value before the object has been initialised.

Any help greatly appreciated.

Best regards,

Fabricio
 
Fabricio Sanchez
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I found my own solution.
Declare the variables outside the public class .. { .. }
So, in my case:



After that, I could access them just the same as public static final ints in java.

Hope this helps someone else.

Cheers,

Fabricio
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic