0

What if I don't pass the string argument in the main function

I know Java takes all the inputs in the string format but what if I pass integer or float as a parameter there?

21st Jul 2016, 7:19 PM
uzma shaikh
2 Respuestas
0
class Test{ public static void main(String arg[]){ System.out.println(arg[0]); System.out.println(arg[1]); } } Run >java Test 1 2.0 What is the output?
21st Jul 2016, 8:04 PM
WPimpong
WPimpong - avatar
0
You can pass in strings, ints, floats, longs etc, they will be parsed in strings and therefore if you need to use them in your program, you need to cast them to your desired type. The method instance of can help you use a conditional statement such as using cases to determine the types of a vast range of command line types of different types by iterating over them and checking what instances they are
22nd Jul 2016, 12:42 AM
Eric Gitangu
Eric Gitangu - avatar