help with creating name

I need to create a name that results in "last, first" the variables are a string for "last name" and a string for "first name" how do i "parse" it to create one name?
[173 byte] By [cocobwarea] at [2007-10-3 7:49:31]
# 1
Have a look at the split() method in the API documentation for java.lang.String. That should do what you need.Brian
brian@cubik.caa at 2007-7-15 2:51:17 > top of Java-index,Java Essentials,New To Java...
# 2
I think the request was to concatenate the names, not split them.last = "Smith";first = "John";lastFirst = last + ", " + first;
ChuckBinga at 2007-7-15 2:51:17 > top of Java-index,Java Essentials,New To Java...
# 3

Is it this what do you wanna do?

public class SplitName {

public static void main(String[] args) {

String name = "Jordan, Michael";

String lastname = "";

int low = 0;

int high = name.length()-1;

String x = "";

while(low <high){

if(name.charAt(low) != ',')

lastname += name.charAt(low);

x += name.charAt(high);

low++;

high -- ;

}

StringBuffer firstname = new StringBuffer(x).reverse();

System.out.println(lastname);

System.out.print(firstname);

}

}

Message was edited by:

Java__Estudante>

Java__Estudantea at 2007-7-15 2:51:17 > top of Java-index,Java Essentials,New To Java...
# 4
I think String.split() or String.substring() would be better options. However as pointed out in reply #2, OP wants concatenation not splitting.
floundera at 2007-7-15 2:51:17 > top of Java-index,Java Essentials,New To Java...
# 5
concatenation ....humm i don't think so , that's to easy .... O.o
Java__Estudantea at 2007-7-15 2:51:17 > top of Java-index,Java Essentials,New To Java...
# 6

> concatenation ....humm i don't think so , that's to

> easy .... O.o

I wouldn't assume so much. For all you know your questions may appear "too easy" to people here as well. It's not a logical conclusion that ANYTHING in forums like these must be too easy for someone to ask about it.

kablaira at 2007-7-15 2:51:17 > top of Java-index,Java Essentials,New To Java...
# 7
> I need to create a name that results in "last, first"Does the code you provided achieve this?
floundera at 2007-7-15 2:51:17 > top of Java-index,Java Essentials,New To Java...
# 8

i didn't mean that :(

ohh it just splits ( x, y ) intoxand y ...doesn't concatenate...

Everyone should ask everything , and don't stop asking .

I didn't mean that , sorry :(

Just thought he wanted to split and not to concatenate..

Btw, does anyone could help me on my code . thank you so much [[]

Message was edited by:

Java__Estudante

Java__Estudantea at 2007-7-15 2:51:17 > top of Java-index,Java Essentials,New To Java...