|
-
Feb 13th, 2003, 11:17 PM
#1
Thread Starter
Frenzied Member
command line arguments
Hello
I am trying to use command line arguments to enter some float variables.
But l am unsure whether the command line arguments will accept anything else other than a string.
My code for this:
[code]
//Create a pool object from the class SwimmingPool, parameters
//to the constructor
Swimming pool = new SwimmingPool(args[0],args[1],args[2],args[3]);
[\code]
when l compile l use this
javac pool 10.0 15.0 10.0 20.0
and get a error message.
public static void main(String[] args)
instead of this could have float instead of string.
If his does not work, is there a way to convert a string data type to a float data type, that would work for me.
Many thanks in advance
-
Feb 14th, 2003, 12:23 AM
#2
Code:
float temp = 0;
String parse = "123.456";
try
{
temp = Float.parseFloat(parse);
System.out.println(temp);
}
catch (NumberFormatException nfe)
{
System.out.println("Invalid number");
}
-
Feb 18th, 2003, 03:18 AM
#3
Lively Member
Hey you shouldn't use javac for running your classes (I'm sure you justed typed wrong, I'm telling you just in case)
/J Lindroos
"My opinions may be have changed, but not the fact that I am right"
< modified by admin. no advertising in sigs>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|