Redian新闻
>
问一简单的问题 关于import
avatar
问一简单的问题 关于import# Java - 爪哇娇娃
j*1
1
发信人: mitbbs (未名空间), 信区: Complain
标 题: Re: [投诉]Trustinjesus版主dignity滥用权力任意删贴
发信站: BBS 未名空间站 (Tue Jun 21 03:46:35 2011, 美东)
处理结果
若未违反版规,且并未涉及攻击,应允许其存在和正常讨论
avatar
t*l
2
我在书上看到,假如 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,今天看书的时候突然想到的,也许根本没有人这么写程序吧
谢谢!
avatar
s*a
3
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();

avatar
t*l
4
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
: 板

avatar
s*d
5
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,
: 么

avatar
s*a
6
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
: 怎
: 吧

avatar
a*a
7
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
: 该
: 序

avatar
N*m
8
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();

avatar
e*3
9
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

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。