Get whole arguments string

Is there a way to get the whole arguments string without enumenrate String [] args?

Thanks in advance

[114 byte] By [agostino75a] at [2007-11-27 11:28:31]
# 1

Why? What's wrong with the String[]?

BigDaddyLoveHandlesa at 2007-7-29 16:22:33 > top of Java-index,Java Essentials,New To Java...
# 2

As of java 5 you have two options:

public static void main(String[] argv) { // code }

public static void main(String... argv) { // code }

... if you don't like it, go back to VB ...

Navy_Codera at 2007-7-29 16:22:33 > top of Java-index,Java Essentials,New To Java...
# 3

public class StringExample {

public static void main(String[] args) {

String[] test = {"hello", "world"};

System.out.format("[%s]%n", join(test));

}

public static String join(String... v) {

StringBuilder b = new StringBuilder();

for(String s : v) {

b.append(s).append(' ');

}

int length = b.length() - 1;

if (length >= 0)

b.setLength(length);

return b.toString();

}

}

BigDaddyLoveHandlesa at 2007-7-29 16:22:33 > top of Java-index,Java Essentials,New To Java...
# 4

> > public class StringExample {

>public static void main(String[] args) {

>String[] test = {"hello", "world"};

>System.out.format("[%s]%n", join(test));

> }

>

>public static String join(String... v) {

>StringBuilder b = new StringBuilder();

>for(String s : v) {

> b.append(s).append(' ');

> }

> int length = b.length() - 1;

> if (length >= 0)

> b.setLength(length);

> rn b.toString();

>}

>

nice.

Navy_Codera at 2007-7-29 16:22:33 > top of Java-index,Java Essentials,New To Java...
# 5

I couldn't find docs about the (String... argv) version. Just tryed it and it seems identical. Where's the difference?

agostino75a at 2007-7-29 16:22:33 > top of Java-index,Java Essentials,New To Java...
# 6

> I couldn't find docs about the (String... argv)

> version. Just tryed it and it seems identical.

> Where's the difference?

The only difference is how you may invoke the method:

void f(String... a) {}

void method(String[] v) {

f(v); //as always

f("hello", "world");

}

BigDaddyLoveHandlesa at 2007-7-29 16:22:33 > top of Java-index,Java Essentials,New To Java...