for(int i = 1; i<arr.length;i++) * System.out.println(arr[i]+ " ");* ** *arr length is 7, but number of strings copied to this array are only 5.* ** *arr[5], arr[6] are gonna be null values..* ** *so, trying to manipulate these null values gonna throw nullpointer Exception.*
On Mon, Aug 16, 2010 at 3:59 PM, Mihai DINCA <[email protected]> wrote: > Hi, > > There still is "for(int i = *1*; i<arr.length;i++)". > > Hope it helps > Mihai > > David Pion a écrit : > > Hi, > > Looks to me like when you copy the args array to the arr array you are > fine, but when you go to print the values you are starting at 1 and you > should start at 0. > > Thank you. > > > > *From:* [email protected] [ > mailto:[email protected]<[email protected]>] > *On Behalf Of *henry joseph > *Sent:* Monday, August 16, 2010 2:17 PM > *To:* [email protected] > *Subject:* [java programming] javase_builtinclasses > > > > Hi, > > > > Even when i start with i= 0, i still dont get the exact number of names > entered on the command line.. > > > > here is my code: > > > > > > public class BuiltInClass { > > > > > > public static void main(String[] args) { > > if(args.length!=5){ > > System.out.println("please, names must be 5 on command > line!!"); > > System.exit(0); > > } > > String []arr = new String[7]; > > for(int i = 0; i<args.length;i++) > > arr[i] = args[i]; > > for(int i = 1; i<arr.length;i++) > > System.out.println(arr[i]+ " "); > > generateNewName(arr); > > > > here is what i get at my output... > > > > run: > > george > > Hney > > Rroy > > Ayilla > > null > > null > > e > > n > > r > > Exception in thread "main" java.lang.NullPointerException > > y > > at BuiltInClass.generateNewName(BuiltInClass.java:43) > > at BuiltInClass.main(BuiltInClass.java:21) > > Java Result: 1 > > BUILD SUCCESSFUL (total time: 3 seconds) > > > > > > i still cant get my zhenny to show.. dont know why, any idea? > > > > > Dont look at where you fell but where you slipped!!! > > > > -- > 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 > -- > 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 > > -- > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected]<javaprogrammingwithpassion%[email protected]> > For more options, visit this group at > http://groups.google.com/group/javaprogrammingwithpassion?hl=en > -- Thanks, Pawan. While one person hesitates because he feels inferior, another is busy making mistakes and becoming superior. Henry C. Link -- 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
