首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

基础测试.该如何解决

2012-03-19 
基础测试.大家如果都不测试.说出程序的执行流程,及输出结果,并分析原因.packagecm.image.iconimportjavax

基础测试.
大家如果都不测试.说出程序的执行流程,及输出结果,并分析原因.
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   );
        }
}


[解决办法]
LZ能给解释一下吗??? 没弄明白为什么结果是这样的.......
[解决办法]
学习 up up 正在学swing 呵呵 初学 能给解释一下吗?? 明天上课我好吹一下 .....
[解决办法]
JFrame继承自Frame,有什么不对么?
[解决办法]
我以为是
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.

[解决办法]
javax.swing.JFrame;

热点排行