t******l 发帖数: 6 | 1 我在书上看到,假如 there are classes with the same name in tow different
package, and then you must either making one or the other calss explicitly, or
you must refer to the class using its fully qualified name.
那我想请问,比如说有一个小程序,都使用 Date class in package java.util and
java.sql
import java.util.Date;
import java.sql.Date;
public class Test
{
Date myDate = new Date();
}
那么这个Date class 到底是谁的? 或者说如果我想说明它是java.util.Date应该怎么板
呢
我这个问题比较STUPID,今天看书的时候突然想到的,也许根本没有人这么写程序吧
谢谢! |
s*a 发帖数: 6 | 2 you need to use full class name here.
java.sql.Date my Date = new java.sql.Date();
or
板
【在 t******l 的大作中提到】 : 我在书上看到,假如 there are classes with the same name in tow different : package, and then you must either making one or the other calss explicitly, or : you must refer to the class using its fully qualified name. : 那我想请问,比如说有一个小程序,都使用 Date class in package java.util and : java.sql : import java.util.Date; : import java.sql.Date; : public class Test : { : Date myDate = new Date();
|
t******l 发帖数: 6 | 3 oh i c lah..
thank you very much!
explicitly,
么
【在 s*a 的大作中提到】 : you need to use full class name here. : java.sql.Date my Date = new java.sql.Date(); : : or : 板
|
s****d 发帖数: 13 | 4 hehe, actually best way is try to compile your java class to see what will
happen.
that will give u deeper impression. :)
and
怎
吧
【在 t******l 的大作中提到】 : oh i c lah.. : thank you very much! : : explicitly, : 么
|
s*a 发帖数: 6 | 5 yes, it is the best way to learn a language, i think.
different
该
序
【在 s****d 的大作中提到】 : hehe, actually best way is try to compile your java class to see what will : happen. : that will give u deeper impression. :) : : and : 怎 : 吧
|
a****a 发帖数: 112 | 6 nod nod, failure is the mom of success. :P
After being tortured by compiler N times, you know how to write
your programs right.
【在 s*a 的大作中提到】 : yes, it is the best way to learn a language, i think. : : different : 该 : 序
|
N***m 发帖数: 4460 | 7 eclipse will let you choose which version.
, or
【在 t******l 的大作中提到】 : 我在书上看到,假如 there are classes with the same name in tow different : package, and then you must either making one or the other calss explicitly, or : you must refer to the class using its fully qualified name. : 那我想请问,比如说有一个小程序,都使用 Date class in package java.util and : java.sql : import java.util.Date; : import java.sql.Date; : public class Test : { : Date myDate = new Date();
|
e********3 发帖数: 18578 | 8 not when both Date classes are referred in the same class, you need to use
the full path explicitly in that scenario.
【在 N***m 的大作中提到】 : eclipse will let you choose which version. : : , or
|