Hi ,
Here is my version:
public static String generateNewName(String[] names){
char[] newname=new char[25];
int j=0;
for(int i=0;i<names.length;i++){
newname[j]=names[i].charAt(1);
j++;
}
return(new String(newname));
}
Regards,
Selva
On Mar 13, 3:05 pm, Wojciech Szymaniuk <[email protected]> wrote:
> Hello everyone
>
> I have written this method in way below:
>
> public static void generateNewName(String[] names1)
> {
> for (int i = 0; i < names1.length; i++)
> {
> char x = names1[i].charAt(1);
> System.out.print(x + " ");
> }
> }
>
> I don't know if it is the best way to do it, but it's working.
>
> Dnia 2009-03-12, czw o godzinie 21:31 +0000, Carlos Lopez pisze:
>
>
>
> > Hi,
>
> > This is my proposal :
>
> > String newName = "";
> > int counter = 0;
> > // Seach 2nd character of each string from the array
> > for (counter = 0; counter < arr.length; counter++) {
> > if (arr[counter] != null) {
> > newName = newName + arr[counter].charAt(1);
> > }
> > }
>
> > 2009/3/12 Ryu <[email protected]>
>
> > Hi to all,
> > Hope everyone is fine. i have a question that what
> > is mean
> > by generate new name after pick the second character .I pick
> > the
> > second character but I add a constant characters at the
> > end ,is this
> > approach right if not then how can i generate new name, use
> > random
> > method approach or any other approach that i can use. Please
> > give me
> > some hint that how i can do this .Here code snippet that i
> > use .
> > Thanks in advance
>
> > //get the second character of the entered name as an argument
> > namesSecondCharacter[counter] =
> > (names[counter]).charAt
> > (1);
>
> > //Print the second character of given argument
> > System.out.println("The second character of
> > names["
> > +counter+ "] is " + namesSecondCharacter[counter]);
>
> > //Replace the entered name with the character at
> > specified index and make new name from it
> > names[counter] = names[counter].replaceAll(names
> > [counter],namesSecondCharacter[counter]+"hume" );
>
> > //Print the new name
> > System.out.println("names[" +counter+ "] is now "
> > + names
> > [counter]);
>
> ----------------------------------------------------------------------
>
> Zyskaj tak jak ja 9% na lokacie w pierwszym miesiacu!
> Sprawdz!http://link.interia.pl/f207b
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---