When I launch the program via cmd, I want to immediately send the necessary arguments to it for further work with them. That is, I write something like C:> java Main arg1 arg2
I need to pass several integers as arguments to this program, but they are accepted as objects of type String. How to pass arguments so that they are perceived as numbers? Is it possible to convert the string "5" to the number 5 in Java? On the Internet, I found a way
a = Integer.parseInt(args[0]); But it works only if you take the args in the right cut. If, for example, try something like
a = Integer.parseInt("5"); That leaves an error. I need to understand this behavior and explain how to transfer integers to a program when it starts via cmd
Also, I would like to know, on the contrary - how can I convert (integer) number (5) into a string ("5") (If possible)
int a = Integer.parseInt("5")- Sergey GornostaevString.valueOf(5)- Sergey Gornostaev