Reputation: 3
The methods is a basic part of the system core.
public java.util.Date getCurDate(){...}
public Date getCurDate(){...}
What is the advantages and disadvantages of writing this return type?
Upvotes: 0
Views: 392
Reputation: 196
If there is no reason to assume there will be conflict with another class called "Date" then there is no need or advantage to write the full name.
Upvotes: 0
Reputation: 5581
The return type needs to specify an unambiguous type. By using a fully qualified type name like java.util.Date
you can be sure it won't be confused with some other Date
class in a different package. However if your import
statement includes java.util.*
or java.util.Date
already, then just saying Date
will be unambiguous enough and the compiler will know which Date
you mean.
Upvotes: 5