+ 1

Who can tell me how many kinds of Java methods there are?

Like, are static,void Java methods?

30th Aug 2016, 12:21 PM
Lawrence Kuo
Lawrence Kuo - avatar
4 ответов
+ 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"); }
30th Aug 2016, 12:29 PM
Ousmane Diaw
0
nice answe. it cleared my questions about methods in java.
4th Sep 2016, 8:28 AM
Medita Bola
Medita Bola - avatar
0
there are only two methods static and non static
18th Dec 2016, 9:54 AM
Mangaranap Parulian Sianturi
Mangaranap Parulian Sianturi - avatar
- 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.
19th Sep 2016, 1:56 PM
Tanya
Tanya - avatar