You have 2 errors in the code, both due to index starting from 1 instead
than from 0.

* for(int i = 1; i<arr.length;i++){//here i couldnt print out the name in
args[0]*
*          System.out.println(arr[i]+ " ");*

you cannot print arr[0] if i start from 1 . On the first loop it will print
arr[1] and in the last loop it will print arr[5] that is not existing.

Change this in

for(*int i = 0*; i<arr.length;i++){//here i couldnt print out the name in
args[0]
          System.out.println(arr[i]+ " ");


Same issue here

*public static void generateNewName(String[] arr){*
*        String name1 = arr[1];*

if you start from arr[1] you will never get arr[0].

change it with

public static void generateNewName(String[] arr){
        String name1 =* arr[0];*

and it should work.

Cheers
TheIrda

2010/8/16 henry joseph <[email protected]>

>
> Hi,
>
> now, i guess i have to post my full code.. I have tried everything.. i just
> don't know why i cant get the args[0] to print..
>
> here is the full 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);
>         }
>           for(int i = 0; i<args.length;i++){ //just to be sure i have the
> right number of names
>               System.out.println(args[i]+ " ");
>           }
>         String []arr = new String[args.length];
>         for(int i = 0; i<args.length;i++){
>            arr[i] = args[i];
> }
>         for(int i = 1; i<arr.length;i++){//here i couldnt print out the
> name in args[0]
>           System.out.println(arr[i]+ " ");
> }
>
>
>         generateNewName(arr);
>
>
>     }
>
>
>     //the static method to generate the names
>     public static void generateNewName(String[] arr){
>         String name1 = arr[1];
>         String name2 = arr[2];
>         String name3 = arr[3];
>         String name4 = arr[4];
>         String name5 = arr[5];
>
>         char a = name1.charAt(1);
>         System.out.println(a + " ");
>         char b = name2.charAt(1);
>          System.out.println(b + " ");
>         char c = name3.charAt(1);
>          System.out.println(c+ " ");
>         char d = name4.charAt(1);
>          System.out.println(d + " ");
>         char e = name5.charAt(1);
>          System.out.println(e + " ");
>
>     }
>
> }
>
> I just do not know why i cannot transfer the args[0] to the arr[0]
>
> 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]<javaprogrammingwithpassion%[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

Reply via email to