当前位置: 技术问答>java相关
JAVA初学,问几个问题……(6个问题)
来源: 互联网 发布时间:2015-02-04
本文导语: 小弟最近接触JAVA,有几个问题,望高手们指教…… ---1--- 什么是序列化(Serializable),继承一个序列化接口的作用是什么? ---2--- 在多线程中,有 Thread.sleep(500); 与 sleep(500); 请问,加Thread与不加Thread有区别吗? ---3--- ...
小弟最近接触JAVA,有几个问题,望高手们指教……
---1---
什么是序列化(Serializable),继承一个序列化接口的作用是什么?
---2---
在多线程中,有
Thread.sleep(500); 与
sleep(500);
请问,加Thread与不加Thread有区别吗?
---3---
在try{} catch(interruptedException e){}中,
catch(interruptedException e){}语句并没有写具体的错误处理,和不写catch语句有什么区别?
---4---
在程序中,frame.pack();或pack();的作用是什么?
---5---
import symantec.itools.awt.Wizard;
symantec.itools.awt.Wizard wizardPanels = new symantec.itools.awt.Wizard();
为什么在IMPORT里已经写入,实例对象时还要写全路径呢?
不是说,在import里引入,就可以直接引用了吗?
---6---
public class SDWMainGmn extends Panel{
MyFrame myframe=new MyFrame();
……
……
}
class MyFrame extends Frame{
……
……
}
为什么先要继承Panel类,再继承Frame类,
而不直接继承Frame类?
Frame类要比Panel类好用一些,难道是因为Panel类有什么特殊的地方吗?
***********************
谢谢各位啦!!!
---1---
什么是序列化(Serializable),继承一个序列化接口的作用是什么?
---2---
在多线程中,有
Thread.sleep(500); 与
sleep(500);
请问,加Thread与不加Thread有区别吗?
---3---
在try{} catch(interruptedException e){}中,
catch(interruptedException e){}语句并没有写具体的错误处理,和不写catch语句有什么区别?
---4---
在程序中,frame.pack();或pack();的作用是什么?
---5---
import symantec.itools.awt.Wizard;
symantec.itools.awt.Wizard wizardPanels = new symantec.itools.awt.Wizard();
为什么在IMPORT里已经写入,实例对象时还要写全路径呢?
不是说,在import里引入,就可以直接引用了吗?
---6---
public class SDWMainGmn extends Panel{
MyFrame myframe=new MyFrame();
……
……
}
class MyFrame extends Frame{
……
……
}
为什么先要继承Panel类,再继承Frame类,
而不直接继承Frame类?
Frame类要比Panel类好用一些,难道是因为Panel类有什么特殊的地方吗?
***********************
谢谢各位啦!!!
|
1、Java provides a storage mechanism for objects in the form of serialization. With the Java way of doing things, you no longer have to worry about details of file formats and I/O. Instead, you are free to concentrate on solving your real-world tasks by designing and implementing objects. If, for instance, you make a class persistent and later add new fields to it, you do not have to worry about modifying routines that read and write the data for you. All fields in a serialized object will automatically be written and restored.
hehe,好长的英文啊,不过解释得不错,borland嘛;
2、线程是可以使同时执行多段代码,不加的话,顺序执行喽;
3、如果catch一个exception,可以让你知道哪里可能会出错,不catch的话,也可以,但是不规范;
4、Frame.pack: Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. If the window and/or its owner are not yet displayable, both are made displayable before calculating the preferred size. The Window will be validated after the preferredSize is calculated.
Pack: pack a set of java code, like zip............;
5、没有见过symantec.itools.awt.Wizard,不过,按说,应该可以不用写全路径的;
6、Panel is the simplest container class. A panel provides space in which an application can attach any other component, including other panels。
Frame is a top-level window with a title and a border.
做法不是唯一的,我觉得可以直接继承Frame类
好累呀,:)
hehe,好长的英文啊,不过解释得不错,borland嘛;
2、线程是可以使同时执行多段代码,不加的话,顺序执行喽;
3、如果catch一个exception,可以让你知道哪里可能会出错,不catch的话,也可以,但是不规范;
4、Frame.pack: Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. If the window and/or its owner are not yet displayable, both are made displayable before calculating the preferred size. The Window will be validated after the preferredSize is calculated.
Pack: pack a set of java code, like zip............;
5、没有见过symantec.itools.awt.Wizard,不过,按说,应该可以不用写全路径的;
6、Panel is the simplest container class. A panel provides space in which an application can attach any other component, including other panels。
Frame is a top-level window with a title and a border.
做法不是唯一的,我觉得可以直接继承Frame类
好累呀,:)