char[] newName = null; This is the line your program is erroring. You don't need to declare a char[]. Re-look at your design.
Keith ________________________________ From: Ahmet Süreyya Rifaioğlu <[email protected]> To: [email protected] Sent: Monday, January 12, 2009 1:43:44 PM Subject: [java programming] Problem in Built in Classes HOMEWORK Hi members, I wrote the homework of Built in Classes, but there is a problem in my function(Exception in thread "main" java.lang.NullPointerException at BuiltinClasses.generateNewName(BuiltinClasses.java:35) at BuiltinClasses.main(BuiltinClasses.java:27)). Here is my code. public class BuiltinClasses { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here if(args.length<3) { System.out.println("You must enter at least three names!!!"); } System.out.println("Names of the family members are "); for(int i=0;i<args.length;i++) { System.out.println(args[i]); } generateNewName(args); } public static void generateNewName(String arr[]) { System.out.println("The new name is "); char[] newName = null; for (int i=0;i<arr.length;i++) { newName[i]=arr[i].charAt(1); System.out.print(newName[i]); } } } Regards --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
