Hi all

 

Please help.  Even though the code below gives the result required, I
have not followed the instructions in the assignment i.e. to write a
method to achieve the result.  I keep on getting errors when I try to
write a Static Method called generateNewName() to get the same output.
Some pointers, please?  PS: why is it necessary to use methods if the
same result can be achieved without it?

 

Thanks

 

 

public class OwnBuiltinClasses {

 

    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

       System.out.println("I am receiving the first names of four family
" +

                " members as command line arguments.. ");

        

        // Check if a command line argument exists

        if(args.length != 4){

            System.out.println("Please enter four names!");

            System.exit(0);

        }

      

        // Assign each name to a variable

       String name1 = args[0];

       String name2 = args[1];

       String name3 = args[2];

       String name4 = args[3];

       String [] familyString = {name1 + name2 + name3 + name4};

       

       System.out.println(name1);

       System.out.println(name2);

       System.out.println(name3);

       System.out.println(name4);

      

       // Select 2nd character in each String name

       char i = name1.charAt(1);

       char j = name2.charAt(1);

       char k = name3.charAt(1);

       char l = name4.charAt(1);       

           

      // Display the names and ages of all family members

      System.out.println("The new first name is = " + i + j + k + l);

      

    }

 

 }

 

Kind regards

 

Rene Erwee

Conveyancing Director

EDELSTEIN-BOSMAN INC

 

222 Lange Street

New Muckleneuk

Pretoria

 

Tel: (012) 452 8900

Fax: (012) 452 8901

E-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 

 

This e-mail and any attachments are confidential and intended solely for
the addressee and may also be privileged or exempt from disclosure under
applicable law. If you are not the addressee, or have received this
e-mail in error, please notify the sender immediately, delete it from
your system and do not copy, disclose or otherwise act upon any part of
this e-mail or its attachments.

Internet communications are not guaranteed to be secure or virus-free.
Edelstein-Bosman Inc does not accept responsibility for any loss arising
from unauthorised access to, or interference with, any Internet
communications by any third party, or from the transmission of any
viruses. Replies to this e-mail may be monitored by Edelstein-Bosman Inc
for operational or business reasons. 

Any opinion or other information in this e-mail or its attachments that
does not relate to the business of Edelstein-Bosman Inc is personal to
the sender and is not given or endorsed by Edelstein-Bosman Inc. 

 


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