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]);
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---