Solved Global Strings and Ints

Discussion in 'Plugin Development' started by frogman6102, May 21, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    frogman6102

    Hello,
    I dont know how to make a global varible in Java. Like so where I can create a String or an ArrayList that can be used anywhere in my plugin.
    Thanks,
    Frogman6102
     
  2. Offline

    oaschi

    Code:java
    1. class Example{
    2. public static String globalVariable;
    3. }


    now you can access the variable:
    Code:java
    1. Example.globalVariable
     
  3. Offline

    MrSparkzz

    frogman6102
    One thing one of my friends like to do was to make a class specifically for global variables.. He used an enumerator class to store all of the variables and had methods stored inside the class that he could call from other classes to get the data from the enums.
     
  4. Offline

    frogman6102

    @MrSparkzzIs there any way I can like save the String (or int) in a class. Also, oaschi, wont the plugin just keep creating a String called globalVariable and not keep one?
     
  5. Offline

    Garris0n

  6. Offline

    frogman6102

    @Garris0nI try to make the int and String to
    public static int Shower;
    But it says Illegal modifiers?
    MrSparkzz
    oaschi
     
  7. Offline

    MrSparkzz

    frogman6102
    remove public and static (this one's not necessary I don't think), you're putting a public variable within a method, either put it outside of all methods or remove the public identifier.
     
  8. Offline

    frogman6102

    MrSparkzz Thank You! LOL, all I had to do was not put it in any methods. Brain Fart.
     
  9. Offline

    MrSparkzz

    frogman6102
    if your issue is resolved, set this thread to solved!
     
  10. Offline

    frogman6102

Thread Status:
Not open for further replies.

Share This Page