what are argument in java
Give example of string arguments and integer arguments.
Answers
Answered by
2
In Java arguments u can only pass the data defined in by the methods.A way around this can be to use objects as an arguments besides that u can create many methods with the same name ,but accepting different arguments.
E.g:-Public Void(As string argument and integer argument).
when using object u need to make sure to check what type it is so u don't end up trying to use an integer as a string and integer arguments.
Hope this helps you
E.g:-Public Void(As string argument and integer argument).
when using object u need to make sure to check what type it is so u don't end up trying to use an integer as a string and integer arguments.
Hope this helps you
Akshat999:
hey.... can u help me in one question
Answered by
2
Short note on Argument in Java:
In Java, An argument is a value that is passed to a method when it is invoked.
String Arguments:
In Java, the Main method accepts the groups of strings which is also called a string type array.This array is string of args.Here args is an array name which is of string type. These are command line arguments.
Ex: String[] args.
Integer Arguments:
We know that Everything passed in from the command line is treated as String as we have discussed above. What if we want to convert a string to a number.
We this we can convert string argument to integer argument whenever necessary.
Ex:String name = "brainly"
int a = Integer.parseInt(name);
System.out.println(a);
Hope this helps!
In Java, An argument is a value that is passed to a method when it is invoked.
String Arguments:
In Java, the Main method accepts the groups of strings which is also called a string type array.This array is string of args.Here args is an array name which is of string type. These are command line arguments.
Ex: String[] args.
Integer Arguments:
We know that Everything passed in from the command line is treated as String as we have discussed above. What if we want to convert a string to a number.
We this we can convert string argument to integer argument whenever necessary.
Ex:String name = "brainly"
int a = Integer.parseInt(name);
System.out.println(a);
Hope this helps!
Similar questions
Social Sciences,
8 months ago
Physics,
1 year ago