+ 1
Who can tell me how many kinds of Java methods there are?
Like, are static,void Java methods?
4 Antworten
+ 9
Firstly a method is simply a block of code that performs a task e.g
public void Method(){
System.out.println("hello world");
}
So no static, void are not methods. void is a return type and static means you can use a certain attribute or method inside a class without needing to make an instance of that particular class.
Finally as far as i know there are two types of methods in java. One which returns a value and one which doesnt e.g
public int MethodA(){
return 1+1;
}
public void Method(){
System.out.println("hello world");
}
0
nice answe.
it cleared my questions about methods in java.
0
there are only two methods static and non static
- 1
As per my knowledge, there are 2 types of methods in java: static methods and non-static methods.
whether a method returns a value or not, doesn't define its type. They are just return types.