java - **Edit** How to get variable/values From main method / void to set it on another project -
i'm trying void method / main method variables have there.
let me put example.
public class test{ static int ten = 10; public static void main(string[] args){ if(something.equals(something)){ ten = 10; <--------- want value } }
so tried this:
public static int getten(){ return ten; }
this works if in main class want use in other functions value.
edit
lets have class called test2
public class test2{ public static void main(string[] args){ here want ten value test1 (other class) can't it. } }
thanks advance.
if want fetch value of ten can pass variable function argument new function eg.
getvalue(ten);
call function in main function , access outside main function
function getvalue(<variable name>){ // print here variable or use }
Comments
Post a Comment