?
Solved

passing argument to java program

Posted on 2004-03-30
7
Medium Priority
?
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

764 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