Solved

passing argument to java program

Posted on 2004-03-30
7
284 Views
Last Modified: 2010-03-31
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
0
Comment
Question by:Kennywen
  • 4
  • 3
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 10720505
java MyProgram "No 2, Street 132, 53000, Malaysia"
0
 

Author Comment

by:Kennywen
ID: 10720525
>> 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
0
 
LVL 92

Expert Comment

by:objects
ID: 10720540
yes and yes :)
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:Kennywen
ID: 10720561
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
0
 
LVL 92

Expert Comment

by:objects
ID: 10720581
should do
0
 

Author Comment

by:Kennywen
ID: 10763459
sorry for late giving point.
0
 
LVL 92

Expert Comment

by:objects
ID: 10763494
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now