Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Replies
    22
    Views
    794

    Re: Java access to another method

    Look at my post#18 to see how to code and use a class level variable.
    Your code still declares randomnumber as local to the onGuildMessageReceived method.

    Also see the tutorial:...
  2. Replies
    22
    Views
    794

    Re: Java access to another method

    Where? Did you post the new version?

    Does it work now?
  3. Replies
    22
    Views
    794

    Re: Java access to another method

    Here is an example of how to declare a variable at the class level:

    class Testing {
    int aClassLevelVar; // declare a class level variable

    public void someMethod() {
    int aLocalVar...
  4. Replies
    22
    Views
    794

    Re: Java access to another method

    Yes, that is how it is coded. Each call will get a new number. That is what the nextInt method does.


    What do you want the gene method to do? Please explain.
  5. Replies
    22
    Views
    794

    Re: Java access to another method

    That method has only local variables which means no other method can see their values. rrr and number are locally defined in the gene method.
    Their values are not accessible outside of the gene...
  6. Replies
    22
    Views
    794

    Re: Java access to another method

    Yes.
    If a method stores a value in a class level variable, that value will be available to any method in the class until some method changes it to a new value.
  7. Replies
    22
    Views
    794

    Re: Java access to another method

    Make a declaration for that variable that is outside of any method but within the definition for the class.
    Remove the variable's declaration from inside of the 'onGuildMessageReceived' method. The...
  8. Replies
    22
    Views
    794

    Re: Java access to another method

    Which one do you want to do?
  9. Replies
    22
    Views
    794

    Re: Java access to another method

    Ok. That looks better.
    Did you try one of the solutions I suggested?
  10. Replies
    22
    Views
    794

    Re: Java access to another method

    What did you change? I do not see the code tags.
  11. Replies
    22
    Views
    794

    Re: Java access to another method

    Either declare it at the class level so all methods can see it
    or pass it as an argument to the method.

    Please edit your post and wrap your code with code tags:



    **YOUR CODE GOES HERE**
Results 1 to 11 of 11