`
leonzhx
  • 浏览: 798788 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
文章列表
Avoid implementing clone. clone is very tricky to implement correctly in all circumstances, nearly to the point of being pathological the importance of copying objects will always remain, since object fields often need to be defensively copied copy constructors and static factory methods pro ...
Qestion: When should I use Thread.getContextClassLoader()?Answer: Although not frequently asked, this question is rather tough to correctly answer. It usually comes up during framework programming, when a good deal of dynamic class and resource loading goes on. In general, when loading a resource ...
Question: Is there a way to determine the generated serialVersionUID of a serialized Java object? The problem is that I serialized an object without explicitely specifying the serialVersionUID . Now the deserialization process complains about class incompatibilities. However I didn't ...
If you ever implemented Serializable interface, you must encounter this warning message The serializable class xxx does not declare a static final serialVersionUID field of type long So…what is serialVersionUID? The serialVersionUID is used as a version control in a Serializable cl ...
Do not implement Serializable lightly, since it restricts future flexibility, and publicly exposes class implementation details which are usually private. As well, implementing Serializable correctly is not trivial.   The serialVersionUID is a universal version identifier for a Serializable class. ...
import java.util.Formatter; public class Test { public static void main(String[] args) { Formatter f = new Formatter(System.out); String s = "MyString"; f.format("%6.10s%%%5.2f", s, 6.9); } }   请问以上程序的输出是:
import java.util.Formatter; public class Test { public static void main(String[] args) { Formatter f = new Formatter(System.out); String s = "MyString"; f.format("%3.4s", s); } }   请问以上程序的输出是:
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class Test { public static void main(String[] args) { List<Object> a = new ArrayList(); Collections.addAll(a, "a", "b", "c", "d&q ...
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class Test { public static void main(String[] args) { List<Object> a = new ArrayList(); Collections.addAll(a, "a", "b", "c", "d&q ...
以下描述中正确的是: 1. 除了 = , == , != 以外,所有运算符只能作用在基本数据类型上。 2. 关系运算符都不能作用在boolean数据上 3. 逻辑运算符只能作用在boolean数据上 4. byte, char, short , int 都是有符号数据(signed) 5. 位运算符 | , & , ~ 也可以作用在boolean数据上 6. 凡是byte, char ,int 参与的运算,都会先各自提升到int再参与运算
public class Test { public static void main(String[] args) { char c = (char) -1; c >>= 3; short s = (short) -1; s >>= 3; System.out.println(c == s); } }   请问以上程序的输出是:
public class Test { public static void main(String[] args) { String a = "AA"; String b = "AA"; System.out.println(a == b); } }   请问以上程序的输出是:
package mypackage; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @interface T ...
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @interface TestAnnotation { pu ...
import java.util.concurrent.TimeUnit; class TestWork { volatile int i = 0; void f() throws InterruptedException { while (i == 0) { synchronized (this) { wait(); } } System.out.println("Waken!"); } void g() { synchronized (this) { i = 1; notifyAll(); ...
Global site tag (gtag.js) - Google Analytics