Link to home
Start Free TrialLog in
Avatar of bde521
bde521

asked on

passing variables as arguments in java

hi.. a number, 500, is being passed as an argument as shown:

p = r.exec(new String[] {"cmd.exe", "/k", "start", "c:\\a\\test.exe", "500"}, null, new File("c:/a"));

can this number be defined as int number and be passed as an argument....  thanks
Avatar of Mick Barry
Mick Barry
Flag of Australia image

no, not really. command arguments are always strings.

If you want to use a int var then you could do this:

int n = 500;
p = r.exec(new String[] {"cmd.exe", "/k", "start", "c:\\a\\test.exe", Integer.toString(n)}, null, new File("c:/a"));
Avatar of bde521
bde521

ASKER

objects.... it works...
one question i may need to pass more than one.... could i just add it to Integer.toString as:
int n = 500;
int x = 120;
p = r.exec(new String[] {"cmd.exe", "/k", "start", "c:\\a\\test.exe", Integer.toString(n, x)}, null, new File("c:/a"));
thanks ....
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bde521

ASKER

objects.. thanks.. bde