大家如果都不测试.说出程序的执行流程,及输出结果,并分析原因.
package cm.image.icon;import javax.swing.*;
import java.awt.*;/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Client { private void test(JFrame frame) {
System.out.println( frame.getClass().getName() );
} private void test(Frame f) {
System.out.println( f.getClass().getName() );
}
public static void main(String args[]) {
Client c = new Client();
Frame f1 = new JFrame();
c.test(f1 );
JFrame f2 = new JFrame();
c.test(f2 );
}
}
package cm.image.icon;import javax.swing.*;
import java.awt.*;/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Client { private void test(JFrame frame) {
System.out.println( frame.getClass().getName() );
} private void test(Frame f) {
System.out.println( f.getClass().getName() );
}
public static void main(String args[]) {
Client c = new Client();
Frame f1 = new JFrame();
c.test(f1 );
JFrame f2 = new JFrame();
c.test(f2 );
}
}
解决方案 »
- JTable表格事件求解
- 一个易语言也能轻松调用win32 API为什么java
- 几个JAVA编程问题请教
- 关于简单的逻辑判断
- 使用spring 自动注入特性的伙计们注意了
- 请高手指教~!如何在JTextArea中获取鼠标的选中的内容?
- 大家帮忙啊,我有一个JAR文件,里面有ANT的build.xml文件,我怎么样操作啊,在ECLIPSE中,感谢
- 在读别人一段代码的时候,遇到了一点不懂的问题。请大家帮忙:)
- 一个关于按钮图象问题。。。。
- 现在的浏览器还支持不支持applet啊?高手救我!--------怎么写一个applet兼容更多的浏览器?
- 有人弄P2P吗?请进来
- 一个简单的算法,如何求100以内7的倍数和????
java.awt.Frame
javax.swing.JFrame
没想到是:
javax.swing.JFrame
javax.swing.JFrame
和下面这个例子一样:
class People
{}
class Student extends People
{}
public class Client
{
public static void main(String args[])
{
People p1 = new Student();
System.out.println( p1.getClass().getName() );
Student p2 = new Student();
System.out.println( p2.getClass().getName() );
}
}
结果:
execices.Student
execices.Student
public final Class<? extends Object> getClass()Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class. Returns:
The java.lang.Class object that represents the runtime class of the object. The result is of type Class<? extends X> where X is the erasure of the static type of the expression on which getClass is called.