Link to home
Start Free TrialLog in
Avatar of Kennywen
Kennywen

asked on

passing argument to java program

i know we can pass the value to java program like:
java MyProgram Hello

Then in the MyProgram:
if ( args.length == 1 )
{
     String Greeting;
     Greeting = args[0];
}

but my problem how can i pass the address to my program? E.g. No 2, Street 132, 53000, Malaysia.

The java will treat each space is a new argument rite?

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 Kennywen
Kennywen

ASKER

>> java MyProgram "No 2, Street 132, 53000, Malaysia"

like this the java will treat it as 1 argument???

then if i write java MyProgram "I'm from" "No 2, Street 132, 53000, Malaysia"
then the java will treat it as 2 arguments???

thanks
yes and yes :)
if the command java MyProgram "I'm from" "No 2, Street 132, 53000, Malaysia" is not type in the console (command prompt) but is call by other program like C++ is't it will work too?

thanks
should do
sorry for late giving point.