+ 1
What does it mean in java?
public static void main(String args[])
13 Respostas
+ 15
Public : an access specifier
Static: a keyword which allows us to run this method without making its object
Void: a return type with no data type
Main : name of method
String []= an string array
Args: name of array
Details of this are given in the course
+ 9
public: Access specifier, this one means that this bit of code can be accessed by any other class or object or whatever
static: a keyword to mark a method as one that can run without an object instance
void: return type, this case meaning that nothing is returned
main: the name of a special method (standard) that acts as an entry point for code
String[] args: An array of strings that are accepted as parameters for the main method.
+ 3
Aman sharma
I think explanation is given here
https://www.sololearn.com/learning/2137/
It's a entry point of Java program.
+ 3
Yes these are correct but make the function static then only you can call the function without any object otherwise you have to make an object to call the methods
+ 3
Aman sharma no it will not work because main method act as a entry point for the program as stated in 👑 Prometheus 🇸🇬 answer you can see there
+ 2
Aman sharma In void methods you can't use return keyword to return the values
you can use the print statement as you are using in any type of methods
+ 2
Yup 👍
+ 1
Oh, thnx I never thought that this String https://www.sololearn.com/learning/2137 could get me what I want 😂
+ 1
₱łɎɄ₴Ⱨ 🇮🇳 If we mark function return type as void then will it be able to return all data types
like if
public void example(int a, int b)
{
int c=a+b;
System.out.print("Your output is");
System.out.print(c);
}
will it return a int and String both
+ 1
are these correct?👇
public int sum(int a, int b)
{
return a+b;
}
sum(5,-5);
And the other one 👇
public void sum(int a,int b)
{
System.out.print("The sum of the two numbers is:"+(a+b));
}
sum(5,-5);
+ 1
Okay just I need to add a static keyword in both the functions after the access specifier 😁
+ 1
₱łɎɄ₴Ⱨ 🇮🇳 Will a program run without method main?
I think No but asked for confirmation.
will a program run if we make a method with this name
public static void anynams(String[] args)
instead of
public static void main(String args[])
+ 1
₱łɎɄ₴Ⱨ 🇮🇳 yeah, I read 👑 Prometheus 🇸🇬 answer but wanted to know if we can use any name for the main method.
Thank you 😁