![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
牛角钻尖
bloodnight
这个作者很懒,什么都没留下…
展开
-
Java是值传递,传对象引用也是通过值
java中是通过 “值” 来拷贝或传递引用引用的“值”的内容应该是代表了堆内存的地址看这个例子:public class Test { public static void main(String[] args) throws InterruptedException { MyObject fp = new MyObject("1"); ...2010-06-02 17:41:07 · 56 阅读 · 0 评论 -
关于维基中singleton pattern的一段
Another notable difference is that static member classes cannot implement an interface, unless that interface is simply a marker. So if the class has to realize a contract expressed by an interf...2011-02-24 10:00:49 · 76 阅读 · 0 评论 -
circumvents exception checking
import java.io.IOException;// Don't do this either - circumvents exception checking!public class Thrower { private static Throwable t; private Thrower() throws Throwable { throw t; ...2011-03-03 11:02:11 · 90 阅读 · 0 评论 -
About gc two objects which are inter referenced to each other
my workmate told me such a senario, there're two objects, which are instantiated in a local method, respectively assigned to local variables. A class has a type B field, B class has a type A field, a...2011-03-08 11:00:13 · 88 阅读 · 0 评论 -
why can bit mask suppress sign extention
yes, bit mask can suppress sign extension, as it changes the number from negative to the positive, you see:byte b = -1;char c = (char)(b & 0xff); b is originally a byte, and it's negative, a...2011-03-10 09:16:24 · 77 阅读 · 0 评论 -
why string concatenation yields no interned one
public class Test { public static void main(String[] args) { String a = "tes"; String b = a + "t"; String c = new String("test"); System.out.println(a.intern() == a); //true System.ou...2011-03-14 16:48:49 · 67 阅读 · 0 评论 -
why is static inner class singleton thread safe?
http://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom public class Singleton { // Private constructor prevents instantiation from other classes private Singleton() { ...2011-03-15 09:03:20 · 87 阅读 · 0 评论 -
about Thread.join method
import java.util.Timer;import java.util.TimerTask;public class Worker extends Thread { private volatile boolean quittingTime = false; public void run() { while (!quittingTime) ...2011-03-23 08:09:22 · 80 阅读 · 0 评论 -
into native source code
once there was a problem occurred from the Thread native mathod start0, what is it?check the source code at j2se\src\share\native\java\lang. http://stackoverflow.com/questions/2292629/where-to-f...2011-03-23 23:09:11 · 90 阅读 · 0 评论 -
why can inner class be instantiated in this way?
public class Outer { public void instantiated() { Inner in = new Inner(); } class Inner { public void a() { } }} class Inner can be instantia...2011-04-06 10:24:49 · 74 阅读 · 0 评论 -
why List hasn't clone method but the ArrayList has
List list = new ArrayList(); for this list, it hasn't the clone method ArrayList arraylist = new ArrayList(); but this arraylist does have clone, why? first, List is an interface, it d...2011-02-16 15:27:09 · 74 阅读 · 0 评论 -
deep copy
static public Object deepCopy(Object oldObj) { ObjectOutputStream oos = null; ObjectInputStream ois = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ...2011-02-16 15:20:22 · 82 阅读 · 0 评论 -
Java is Pass-by-Value
This often heard saying is not correct: "primitives are passed by value, and objects are passed by reference" in Java everything is passed by value. Primitives are passed by value, and object re...2011-02-14 13:28:33 · 173 阅读 · 0 评论 -
由JFrame的title引起的String传递问题
import javax.swing.JFrame;public class Main { public static void main(String[] args) throws Exception { String title = "abc"; JFrame jframe = new JFrame(title); jframe.setVisible(true...2010-12-29 16:48:42 · 151 阅读 · 0 评论 -
Struts2之log信息不出的问题
刚开始学习Struts2的时候,用的是maven方式,但是却不如官方文中所指的出log信息 http://struts.apache.org/2.2.1/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html 就是文末提到的:...2010-12-30 11:18:37 · 185 阅读 · 0 评论 -
无符号右移>>>
public class Test { public static void main(String args[]) { byte b = (byte) 0xf1; byte c = (byte) (b >> 4); byte d = (byte) (b >>> 4); byte e = (byte) ((b & 0xff) >...2011-01-11 15:46:33 · 204 阅读 · 0 评论 -
生成几个String的问题
public class Test extends java.lang.Object{public Test(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."<init>":()V 4: returnpublic static void ma...2011-01-11 16:26:03 · 78 阅读 · 0 评论 -
Enum singleton - Elvis Stealer
import java.io.ByteArrayInputStream;import java.io.InputStream;import java.io.ObjectInputStream;public class ElvisImpersonator { // Byte stream could not have come from real Elvis instanc...2011-04-26 14:41:30 · 127 阅读 · 0 评论 -
关于iterator的fail-fast
是使用集合的iterator后,再改变就可能抛出这个异常 The iterators returned by all of this class's "collection view methods" are fail-fast: if the map is structurally modified at any time after the iterator is create...2011-01-20 11:15:50 · 98 阅读 · 0 评论 -
why concrete class must implement abstract method while abstract class need not
yes, just as the title...why concrete class must implement abstract method while abstract class need not. Here we have two cases, one is concrete class extends abstract class, the other is abstract cl...2011-05-11 13:27:10 · 173 阅读 · 0 评论 -
没有实现抽象方法的具体类居然编译通过了
来自csdn:http://topic.csdn.net/u/20110131/09/7099a295-3877-4b2d-81bd-46137e5530c9.html package pack1;public abstract class A { abstract void set();} package pack2;import pack1.A;...2011-02-04 22:29:49 · 97 阅读 · 0 评论 -
不是说字符串不可变吗
from csdn: http://topic.csdn.net/u/20110213/20/ea6b5231-7397-41fb-a34d-349d4f29144d.html?seed=532705613&r=71600365#r_71600365 问:不是说字符串是不可变的吗,string s="abc";s="123"不就是变了吗? 答:* 不变指的是String对象...2011-02-14 11:28:28 · 81 阅读 · 0 评论 -
NullPointerException in ternary operator
java代码:Integer i = null;Integer x = true ? i : 1; assembly code:public static void main(java.lang.String[]); Code: Stack=1, Locals=3, Args_size=1 0: aconst_null 1: ...2013-01-19 00:01:25 · 194 阅读 · 0 评论