I am trying to write program which takes name as input from command line and sort by last name, displayed in format last name, first name. Here is my code which gives dereferencing null pointer error. public static void main(String[] args) if(args[0].equals("slst")) { System.out.println("Here is a list of the names as read in:"); for(String s: args_name) { System.out.println(s); } System.out.println("Press Enter to continue ... "); keyboard.nextLine(); System.out.println("And here is a list of the name sorted by last" + " name, displayed in the format Last, First"); String firstName = name.substring(1,name.indexOf(" ")); String lastName = name.substring(name.indexOf(" ") +1); String slst = lastName + ", " + firstName; System.out.println(slst); | 0 |