Computer Science, asked by Akshat999, 1 year ago

what are argument in java
Give example of string arguments and integer arguments.

Answers

Answered by AngelT
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

Akshat999: hey.... can u help me in one question
AngelT: ya sure why not
AngelT: plz ask
Akshat999: its given we have to take one string argument(string str) and one integer argument(int p)..... it displays all the upper case characters if p is 1 otherwise all the lowercase characters.
Answered by siddhartharao77
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!

siddhartharao77: Gud Luck!
Akshat999: thank u very much
Similar questions