user1709237
user1709237

Reputation:

How to parse a string from arguments Java?

I have been trying to parse a string from arguments, I have tried

String.parseString(args[0]);

what exactly am I doing wrong?

Upvotes: 0

Views: 16552

Answers (2)

Tony Meng
Tony Meng

Reputation: 353

args[0] should already be a string if it's coming from command line.

If not, use String.valueOf(args[0]).

See http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html

Upvotes: 3

Reimeus
Reimeus

Reputation: 159754

As the args argument in the main method is already a String array, you can just use args[0].

There is no such method String.parseString() btw.

Upvotes: 2

Related Questions