3

How to return array and print

view full story
linux-howto

http://www.daniweb.com – Hello. I am trying to return an array and print the values. public class Sample {         public static void main(String args[]){                                                 for (int i = 0 ; i<getNames().length;i++){                         String a[] = new String[getNames().length];                         System.out.println(a[0]);                 }         }                 public static String[] getNames() {                   String names[] = {"bob", "jim"};                   return names;                 } } But when i ran the program, I've got the output: null null Help. I can't figure it out. Thank you again. (General)