Calling a variable from a void method

handroski

Hey this is a very simple question. Can I call a variable, in this case an array, from a void method? I have declared my arrays at the class level and initialized them in a void method. Not sure it I am doing this correctly but I am trying to call the array from another class. I am a beginner. Thank you for the help.

ex:

public class HeyThere{
    public double me[];

    public void yeahYou(int you){
        me = new me[69]
    }
}
Shiva

Yes, since your class level array me is scoped as Public, you will be able to access it from another class after you instantiate the HeyThere class.

Ex:

public class HeyThereCaller
{
..
....
    public void SomeMethod()
    {
    ...
    ....
    HeyThere heyThereInstance = new HeyThere();
    double[] meArray = heyThereInstance.me;
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling a static void Java method from JNI

From Dev

Calling a void Method into a constructor

From Dev

Calling a void method

From Java

Passing variable number of parameters from calling method

From Dev

undefined local variable or method from &block when calling instance method

From Java

How to use value of a variable from a loop in a void method

From Dev

Get name from variable in calling method - creating calling method signature, parameters and values

From Dev

Calling a parent method from a child class with a variable of that child

From Java

Calling Java method that receive variable amount of parameters from Scala

From Dev

Rails calling create method from same controller instance variable

From Dev

Pass IApp app variable to private methods from calling public method

From Dev

Passing the return from a yield block to a variable in the calling method

From Dev

Calling overrided method on Derived class casted from void ptr causes segmentation fault

From Java

Mockito assert after calling a void method

From Dev

Calling a method from a superclass

From Dev

Calling method from view

From Java

Calling method from constructor

From Dev

Calling a method from arraylist

From Dev

Calling a method from a class

From Java

Calling a method from another method

From Dev

Calling a function from variable

From Dev

Calling a method (stored in a variable) in a closure

From Dev

Mocking local variable in calling method

From Dev

mocking of instance void method is working without calling 'expectLastCall' method

From Dev

Calling a ViewPart(SWT) from void main

From Dev

Calling a function from the return statement of a void function

From

Why does calling a method on a variable prevent Rust from inferring the type of the variable?

From Dev

Writing to a file from a void method

From Dev

Accessing a variable in a void from main

Related Related

  1. 1

    Calling a static void Java method from JNI

  2. 2

    Calling a void Method into a constructor

  3. 3

    Calling a void method

  4. 4

    Passing variable number of parameters from calling method

  5. 5

    undefined local variable or method from &block when calling instance method

  6. 6

    How to use value of a variable from a loop in a void method

  7. 7

    Get name from variable in calling method - creating calling method signature, parameters and values

  8. 8

    Calling a parent method from a child class with a variable of that child

  9. 9

    Calling Java method that receive variable amount of parameters from Scala

  10. 10

    Rails calling create method from same controller instance variable

  11. 11

    Pass IApp app variable to private methods from calling public method

  12. 12

    Passing the return from a yield block to a variable in the calling method

  13. 13

    Calling overrided method on Derived class casted from void ptr causes segmentation fault

  14. 14

    Mockito assert after calling a void method

  15. 15

    Calling a method from a superclass

  16. 16

    Calling method from view

  17. 17

    Calling method from constructor

  18. 18

    Calling a method from arraylist

  19. 19

    Calling a method from a class

  20. 20

    Calling a method from another method

  21. 21

    Calling a function from variable

  22. 22

    Calling a method (stored in a variable) in a closure

  23. 23

    Mocking local variable in calling method

  24. 24

    mocking of instance void method is working without calling 'expectLastCall' method

  25. 25

    Calling a ViewPart(SWT) from void main

  26. 26

    Calling a function from the return statement of a void function

  27. 27

    Why does calling a method on a variable prevent Rust from inferring the type of the variable?

  28. 28

    Writing to a file from a void method

  29. 29

    Accessing a variable in a void from main

HotTag

Archive