| One thing to note here is that you don't actually need to use the "import" feature, it just saves you a lot of typing.
It becomes rather clear in this example:
import java.util.Date
public Date getNormalDate(){
return new Date();
}
public Date getSQLDate(){
return new Date();
}
Since you've imported java.util.Date your program will use that Date for both of your methods, but since I actually named one of my methods "getSQLDate()" I most likely don't want the normal Date on that method, but rather the sql date. To avoid the error here you'd have to do the following:
import java.util.Date
public Date getNormalDate(){
return new Date();
}
public java.sql.Date getSQLDate(){
return new java.sql.Date();
}
And thus you probably will be able to see that you don't need the import at all, it's just a short for typing "new Date()" instead of "new java.util.Date();"
So it would be perfectly ok to do the same on the getNormalDate() and thus skipping the import:
public java.util.Date getNormalDate(){
return new java.util.Date();
}
You'll most likely run into the problem of using two different classes with the same name, and that is exactly how you solve that issue. |