arraylist - Java Array returns Null -


so when use pick string of random events returns null:

public static list<string> picknrandom(list<string> lst, int n) {     list<string> copy = new linkedlist<string>(lst);     collections.shuffle(copy);     return copy.sublist(0, n); }  static list<string> randomp; public list<string> items(){     list<string> teamlist = new linkedlist<string>();     teamlist.add("team1");     teamlist.add("team2");     teamlist.add("team3");     teamlist.add("team4");     teamlist.add("team5");     teamlist.add("team6");     list<string> randompicks = picknrandom(teamlist, 3);     randompicks = randomp;     return randompicks; }  public static void store() {     random rand = new random();     int people = rand.nextint(50) + 1;     list<string> itemsin = randomp;     system.out.println("people in store: "+people + "\nitems in store: "+itemsin); }  public static void main(string[] args) {     store();  } 

why returning null , can fix this?

in line list<string> itemsin = randomp; assign list not initialized default value null. think that's how line should like: list<string> itemsin = items(); remember change method items() static.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -