How do I make an array accessible to all methods in Java?

We have this chain array declared in the code, but I have to declare that once with my main method along with another time period in my personal static method.How should i declare it to ensure I any longer ! have this kind of array fact appear twofold in my own code

Stringed MonthArray = “January”, “February”, “March”, “April”, “M
“August”, “September”, “October”, “November

declare it beyond the principal method and so it’s global

criminal court static String MonthArray = “January”, “February”, “March”…;

criminal court static emptiness main(String args)
….

declare that outside the principle function
or go it towards second purpose as argument after which you can use it
example
criminal court static fn(String s)

//function body use number with brand s

now around main do like this to contact the function
fn(MonthArray);

Declare the actual array before the main purpose.This allows any function to get into that number.

Leave a Reply