+ 1
Why are we creating the object this way?
Say my code is this:- Intent myIntent = Intent.createChooser(intent, "Send message..."); Is myIntent an object? Why is it written "Intent.createChooser(intent, "Send message...");" I mean i know what it does but, why is it written this way? This ain't the normal way of creating objects right?
3 Antworten
+ 2
Mons Joseph
Yes here myIntent is an object which is returned by your static method createChooser.
If you call method with class name that method would be static.
+ 3
Mons Joseph
You should read about "static" keyword 👇
https://www.sololearn.com/learn/Java/2159/
+ 1
It's somewhat of a design pattern. If you look it up you.
Design patterns help to write robust and reusable code.
In this case it could be a creational pattern that creates an instance of class.