How to use array variable defined outside main method in Java -


public class tostring  {   string mystr[] = {"a","b","c"};   public static void main(string[]args)   {       mystr[] mystr1 = new mystr[];        system.out.print(mystr.tostring());   } } 

  1. make array variable static if wish use in static method.
  2. use system.out.println(java.util.arrays.tostring(mystr)); if want see string representation makes sense. otherwise you're going see non-sense you.
  3. get rid of line mystr[] mystr1 = new mystr[]; doesn't make sense.
  4. in future, please tell problems having code you've posted, including error messages might seeing. please go through tour, help , how ask question sections see how site works , improve current , future questions, can better answers.

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -