posted 21 years ago
What's the problem with using a temporary variable?
If you are convinced that you don't want to use one, the only way that I can think of is to define a separator character e.g. '#', "append" it to the end of one of the Strings followed by the other String and then parse the required bit of the compound String into each variable.
e.g.
String one = "one" ;
String two = "two" ;
one = one + "#" + two ;
int separatorIndex = one.indexof( '#' );
two = one.substring( 0, separatorIndex );
one = one.substring( separatorIndex );
Or something like that.
This will of course end up creating a number of new objects while during the manipulation as Strings are immutable thereby negating any performance gain that you would have achieved by not specifying an extra variable.
Jeremy.