在序列化和反序列化期间如何调用构造函数
int为32位和long/ double或64位.这些尺寸是否保持相同
long/ double原子的?读取和写入对于引用变量和大多数原始变量(除long和double之外的所有类型)都是原子的.
这个陈述与jvm/processor架构有什么关系吗?有人可以解释一下.
3.如果我使用64位jvm和处理器,最后我将能够读/写双/长原子
说"Java Modified UTF-8 Encoding"是什么意思?它与普通的UTF-8编码有什么不同?
try {
for(;;) {
s.add("Pradeep");
}
} finally {
System.out.println("In Finally");
}
Run Code Online (Sandbox Code Playgroud)
在try块中,jvm耗尽了内存,那么jvm在没有内存的情况下如何最终激活块?
输出:
In Finally
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
Run Code Online (Sandbox Code Playgroud) catch (IOException|SQLException ex) {
logger.log(ex);
throw ex;
}
Run Code Online (Sandbox Code Playgroud)
这里为什么ex隐含最终?使用ex隐式最终有什么用?
/*1.*/ List l = new ArrayList<Number>();
/*2.*/ List<String> ls = l; // unchecked warning
/*3.*/ l.add(0, new Integer(42)); // another unchecked warning
/*4.*/ String s = ls.get(0);
Run Code Online (Sandbox Code Playgroud)
如果第2行和第3行产生未经检查的警告,那么为什么第4行不会生成未经检查的警告,因为编译器不知道'ls'指的是什么(List<String>或List<Integer>).
(注意:从OP的原始帖子进行编辑,以使代码显示为可能的 - 特别是包括List<E>所有地方的类型参数.)
List l = new ArrayList<Number>();
Run Code Online (Sandbox Code Playgroud)
l的静态类型是List?这里的"静态类型"是什么意思?我在sun的java教程中读到了它
标题告诉我的需要,以下是我使用的代码:
SameObjectDifferentStreams same = new SameObjectDifferentStreams();
ObjectOutputStream out1 = new ObjectOutputStream(new FileOutputStream("file1"));
ObjectOutputStream out2 = new ObjectOutputStream(new FileOutputStream("file2"));
out1.writeObject(same);
out1.close();
out2.writeObject(same);
out2.close();
System.out.println("The Original reference is :" + same.toString());
oin1 = new ObjectInputStream(new FileInputStream("file1"));
oin2 = new ObjectInputStream(new FileInputStream("file2"));
SameObjectDifferentStreams same1 =
(SameObjectDifferentStreams) oin1.readObject();
System.out.println("The First Instance is :" + same1.toString());
SameObjectDifferentStreams same2 =
(SameObjectDifferentStreams) oin2.readObject();
System.out.println("The Second Instance is :" + same2.toString());
Run Code Online (Sandbox Code Playgroud)
The Original reference is :serialization.SameObjectDifferentStreams@9304b1
The First Instance is :serialization.SameObjectDifferentStreams@190d11
The Second Instance is :serialization.SameObjectDifferentStreams@a90653
Run Code Online (Sandbox Code Playgroud) public class PersistentAnimation implements Serializable, Runnable
{
private Thread animator;
private int animationSpeed;
public PersistentAnimation(int animationSpeed)
{
this.animationSpeed = animationSpeed;
animator = new Thread(this);
}
public void run()
{
while(true)
{
// do animation here
}
Run Code Online (Sandbox Code Playgroud)
此处的动画师是否未标记为瞬态?它会继续存在吗?
FileInputStream in = new FileInputStream("filetoreadfrom.txt");
while ((c = in.read()) != -1) {
Integer cobj = new Integer(c);
System.out.println("The Current data being read is :" + cobj.byteValue());
out.write(c);
}
Run Code Online (Sandbox Code Playgroud)
sysout给出一个表示正在读取的字节的intvalue.但我想打印正在读取的字符.有没有办法做到这一点?