Java, Software Development

Java – How to pass argument string with spaces to Java

The way you run your application in Java is by invoking java followed by the class name (without the .class extension).

Here you are not passing any arguments (or parameters) to the application.

The only entry-point of any Java application is through this

The method signature indicates that it accepts arguments.

Our Awesome App Codes

Without passing any argument, our application displays

Passing Arguments

Let’s pass a one-word string and see what happens

This displays

Now let’s pass a string with more than one word

This outputs

Clearly not the input we would want.

To display all the words in this is super! enclosed them in quotes. Like this one,

This outputs

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like