有趣的code
xiaomin_____
努力~~
展开
-
有趣的代码一
public class Test { private static String LOCATION; static Integer x = 1; static Integer y = 1; static Integer x1=11111; static Integer y2=11111; public static void main(String[] args) {...原创 2012-02-01 23:46:24 · 118 阅读 · 0 评论 -
jvm 内存分配
public class T { private String a = "aa"; public void t(){ String b = "bb"; final String c = "cc"; }}请问这3个a,b,c分别在内存的什么存储区存放? 通过javap -verbose T 查看 jdk6,7 发现a b 在常量池,c...原创 2015-12-09 10:56:22 · 96 阅读 · 0 评论 -
java string
public class Day{private static String getA(){return "a";}private static void method1(){String a ="a"+"b"+1;String b ="ab1";System.out.println(a==b);//a,b均为常量,在编译时就已经确定}...原创 2015-08-17 10:34:21 · 88 阅读 · 0 评论 -
模拟鼠标桌面点击(桌面机器人)
/** * [Product] * SaaS * [Copyright] * Copyright © 2014 xxxx All Rights Reserved. * [FileName] * APP.java * [History] * Version Date Author ...原创 2015-07-01 16:13:27 · 256 阅读 · 0 评论 -
java clinit 死锁
public class StaticInit { public static void main(String[] arg) { Thread th1 = new Thread(new Runnable() { public void run() { System.out.println(B.bStr); } }, "call-bStr");...原创 2013-06-01 19:07:50 · 172 阅读 · 0 评论 -
i++ 与 ++i
public class T4{ /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int s = 0; //String a = s.concat("a"); //...原创 2012-04-19 09:31:31 · 93 阅读 · 0 评论 -
++i
public class T3{ /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int s = 0; //String a = s.concat("a"); ...原创 2012-04-18 22:14:12 · 95 阅读 · 0 评论 -
i++ (二)
public class T{ /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int s = 0; //String a = s.concat("a"); ...原创 2012-04-18 21:43:01 · 160 阅读 · 0 评论 -
方法重载
public class TestCode { public void myMethod(String s) { System.out.println("My String"); } public void myMethod(Object o) { System.out.println("My Object")...原创 2012-04-18 20:00:28 · 82 阅读 · 0 评论 -
happens befor 原则?
public class T extends Thread { @Override public void run() { System.out.println("a"); throw new RuntimeException("runtionException"); } public static void main(String[] args) { new T().start()...原创 2012-07-09 23:05:40 · 98 阅读 · 0 评论 -
cinit init
public class Test { private static Test tester = new Test(); // step 1 private static int count1; // step 2 private static int count2 = 0; // step 3 public Test() { // step 4 count1++; ...原创 2012-02-28 09:43:13 · 159 阅读 · 0 评论 -
jvm 初始化
package test;public class A { private static A a = new A(); private B b = B.getInstance(); private A() { } public static A getInstance() { System.out.println("A被调用"); retur...原创 2012-02-17 15:13:49 · 113 阅读 · 0 评论 -
i++
public class Test { public static void main(String... args) { int i = 0; i = i++; System.out.println(i); }}使用javac编译后再使用javap -c Test反编译这个类...原创 2012-02-17 14:55:09 · 122 阅读 · 0 评论 -
List,Map,Set add方法
import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.List;import java.util.Map;import java.util.Set;public class MapTest { public static void...原创 2012-02-17 11:28:47 · 110 阅读 · 0 评论 -
jdk6 vs jdk7 string intern 区别
package com.goods;class Test{ /** * jdk6 vs jdk7 string intern 区别 * 6:将字符串加入常量池.返回常量值。(不改变当前引用) * 7:将字符串加入常量池.返回常量值。(改变当前引用)1、判断常量池中是否有该值,没有的话将该字符串加入常量池,并返回常量值,2.常量池中有的话,就返回当前的内存地址...原创 2016-02-24 19:00:02 · 160 阅读 · 0 评论