Here is the full code that will run..

All are suggesting the same thing to change few lines of code in your
program.. Not sure why you are not getting it..



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 = 0; i<args.length;i++){//here i couldnt print out the
name in args[0]
          System.out.println(arr[i]+ " ");//changed the arr.length to
args.length*
}


        generateNewName(arr);


    }


    //the static method to generate the names
    public static void generateNewName(String[] arr){
  *String name0 = arr[0];*
  String name1 = arr[1];
        String name2 = arr[2];
        String name3 = arr[3];
        String name4 = arr[4];
   *    // String name5 = arr[5];/* no arr[5] as it is null value*

  char e = name0.charAt(1);
        System.out.println(e + " ");
        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);no arr[5] as it is null value
       //  System.out.println(e + " ");no arr[5] as it is null value*

    }

On Mon, Aug 16, 2010 at 5:50 PM, henry joseph <[email protected]> wrote:

>
> 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




-- 
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

Reply via email to