java - How can i call a variable from another method -



java - How can i call a variable from another method -

i need know how phone call variable 1 method can help me?

public static void number(){ number = 1; } public static void callnumber(){ /*how can phone call number method??? */ }

actually, "call variable other method" not explicit, since variable in method either global (used in method naturally available in entire program), or local variable of method. , in lastly situation impossible value.

then either declare variable externally , trivial, or specifiy type value method "number()":

public static int number() { int number = ...; homecoming number; }

and phone call it:

public static void callnumber() { int numberreturned = number(); // other things... }

note: code number = 1; specifies variable global... trick set "number" available either return of method, or specifying variable global.

i don't know if i've answered question, if not seek more explicit.

java methods call

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -