0

What is the meaning of these sentence...

I don't understand the meaning of this sentence. Thank you for helping me. The sentence is : "The methods in the Collections class are static, so you don't need a Collections object to call them." It is hard for me to understand these two concepts: "static" and the action to calling methods. This is so strange for a beginner programmer!

1st Jun 2017, 10:47 PM
Daniel Dulude
Daniel Dulude - avatar
3 Réponses
+ 2
If method is static you don't need to call it like $class->method(), you can call it like Class::Method().
1st Jun 2017, 11:16 PM
Krzysztof Przybylowski
Krzysztof Przybylowski - avatar
+ 2
The only thing that you need to understand is that a non static method needs an object to access whereas for static method we can directly access by using Class-name. For example, here Collections.sort():
2nd Jun 2017, 12:06 AM
Keshav Kumbham
Keshav Kumbham - avatar
0
thank you very much both of you 😊
2nd Jun 2017, 12:18 AM
Daniel Dulude
Daniel Dulude - avatar