亚洲精品国产高清不卡在线,亚洲国产av玩弄放荡人妇,亚洲人精品午夜射精日韩http://www.tkk7.com/sevenduan/category/43076.html無論怎樣,請讓我先感謝一下國家。zh-cnSun, 18 Jul 2010 14:40:41 GMTSun, 18 Jul 2010 14:40:41 GMT60Java logging frameworkhttp://www.tkk7.com/sevenduan/archive/2010/07/18/326473.htmlsevenduansevenduanSun, 18 Jul 2010 14:15:00 GMThttp://www.tkk7.com/sevenduan/archive/2010/07/18/326473.htmlhttp://www.tkk7.com/sevenduan/comments/326473.htmlhttp://www.tkk7.com/sevenduan/archive/2010/07/18/326473.html#Feedback0http://www.tkk7.com/sevenduan/comments/commentRss/326473.htmlhttp://www.tkk7.com/sevenduan/services/trackbacks/326473.html Framework Supported log levels Standard appenders Popularity Cost / licence Log4J FATAL ERROR WARN INFO DEBUG TRACE AsyncAppender, JDBCAppender, JMSAppender, LF5Appender, NTEventLogAppender, NullAppender, SMTPAppender, SocketAppender, SocketHubAppender, SyslogAppender, TelnetAppender, WriterAppender Widely used in many project and platforms Apache License, Version 2.0 Java Logging API SEVERE WARNING INFO CONFIG FINE FINER FINEST Depends on the underlying framework; Sun's default Java Virtual Machine (JVM) has the following: ConsoleHandler, FileHandler, SocketHandler, MemoryHandler Not widely used[citation needed] Comes with the JRE Apache Commons Logging FATAL ERROR WARN INFO DEBUG TRACE Depends on the underlying framework Widely used, in conjunction with log4j Apache License, Version 2.0 SLF4J ERROR WARN INFO DEBUG TRACE Depends on the underlying framework, which is pluggable Probably small but growing MIT License

sevenduan 2010-07-18 22:15 發表評論
]]>
java transaction summaryhttp://www.tkk7.com/sevenduan/archive/2010/04/25/319319.htmlsevenduansevenduanSun, 25 Apr 2010 08:44:00 GMThttp://www.tkk7.com/sevenduan/archive/2010/04/25/319319.htmlhttp://www.tkk7.com/sevenduan/comments/319319.htmlhttp://www.tkk7.com/sevenduan/archive/2010/04/25/319319.html#Feedback0http://www.tkk7.com/sevenduan/comments/commentRss/319319.htmlhttp://www.tkk7.com/sevenduan/services/trackbacks/319319.html1 definition:

“A transaction is a complete unit of work. It may comprise many computational tasks,which may include user interface, data retrieval, and communications. A typicaltransaction modifies shared resources.”

2 transaction features:
ACID (atomicity, consistency, isolation, durability)

3 java spec
JTA, JTS
 1interface javax.transaction.TransactionManager
 2{
 3public abstract void begin();
 4public abstract void commit();
 5public abstract int getStatus();
 6public abstract Transaction getTransaction();
 7public void resume(Transaction tobj);
 8public abstract void rollback();
 9public abstract void setRollbackOnly();
10public abstract void setTransactionTimeout(intseconds);
11public abstract Transaction suspend() ;
12}

4 Common XAResource
JDBC 2.0:
A JDBC driver that supports distributed transactions implements the javax.transaction.xa.XAResource interface, the javax.sql.XAConnectioninterface, and the  javax.sql.XADataSource interface.

JMS 1.0:

a JMS provider javax.transaction.xa.XAResource interface, the implements the javax.jms.XAConnection and the javax.jms.XASession interface.

5 Common TransactionManager

5.1 EJB Transaction Options:
NotSupported
    If the method is called within a transaction, this transaction is suspended during the time of the method execution.
Required
    If the method is called within a transaction, the method is executed in the scope of this transaction; otherwise, a new transaction is started for the execution of the method and committed before the method result is sent to the caller.
RequiresNew
    The method will always be executed within the scope of a new transaction. The new transaction is started for the execution of the method, and committed before the method result is sent to the caller. If the method is called within a transaction, this transaction is suspended before the new one is started and resumed when the new transaction has completed.
Mandatory
    The method should always be called within the scope of a transaction, else the container will throw the TransactionRequired exception.
Supports
    The method is invoked within the caller transaction scope; if the caller does not have an associated transaction, the method is invoked without a transaction scope.
Never
    The client is required to call the bean without any transaction context; if it is not the case, a java.rmi.RemoteException is thrown by the container.

5.2 Spring transaction:
      Transaction isolation: The degree of isolation this transaction has from the work of other transactions. For example, can this transaction see uncommitted writes from other transactions? avaliable options:
ISOLATION_DEFAULT
ISOLATION_READ_UNCOMMITTED
ISOLATION_READ_COMMITTED
ISOLATION_REPEATABLE_READ
ISOLATION_SERIALIZABLE

      Transaction propagation: Normally all code executed within a transaction scope will run in that transaction. However, there are several options specifying behavior if a transactional method is executed when a transaction context already exists: For example, simply running in the existing transaction (the most common case); or suspending the existing transaction and creating a new transaction. Spring offers the transaction propagation options familiar from EJB CMT. avaliable options:
PROPAGATION_MANDATORY
PROPAGATION_NESTED
PROPAGATION_NEVER
PROPAGATION_NOT_SUPPORTED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRES_NEW
PROPAGATION_SUPPORTS

      Transaction timeout: How long this transaction may run before timing out (automatically being rolled back by the underlying transaction infrastructure).
      Read-only status: A read-only transaction does not modify any data. Read-only transactions can be a useful optimization in some cases (such as when using Hibernate).


6 transaction for web service
Protocol specifications:
WS-Transaction
OASIS Business Transaction Protocol (BTP)
Java API
JAXTX (JSR-156)

 



sevenduan 2010-04-25 16:44 發表評論
]]>
java nest class and java inner classhttp://www.tkk7.com/sevenduan/archive/2010/04/17/318623.htmlsevenduansevenduanSat, 17 Apr 2010 15:07:00 GMThttp://www.tkk7.com/sevenduan/archive/2010/04/17/318623.htmlhttp://www.tkk7.com/sevenduan/comments/318623.htmlhttp://www.tkk7.com/sevenduan/archive/2010/04/17/318623.html#Feedback5http://www.tkk7.com/sevenduan/comments/commentRss/318623.htmlhttp://www.tkk7.com/sevenduan/services/trackbacks/318623.html 比如說,我想創建10個函數,每個函數依次返回0-9.
 1 //wrong: all function refer to global variable i=10 
 2 var fn_list=[];
 3 for(var i=0;i<10;i++){
 4  var _tempFn =function(){
 5         return i;
 6  }
 7  fn_list.push(_tempFn);    
 8 }
 9 //right: every function refer to its closure scope variable a
10 var fn_list=[];
11 for(var i=0;i<10;i++){
12  var _tempFn =function(a){
13         return function(){
14          return a;
15         };
16  }
17  fn_list.push(_tempFn(i));    
18 }
19 

Java里也有兩個讓初學者容易混淆的概念:nest class and inner class。
nest class就是static inner class,
而inner class就是no-static inner class。沒有為什么,sun就是這么定義的。
還是上面得例子,創建10個對象,每個對象的getValue接口依次返回0-9.
 1 public class Test {
 2     private int noStaticValue;
 3     private static int staticValue;
 4 
 5     public Test(int noSV, int sv) {
 6         this.noStaticValue = noSV;
 7         this.staticValue = sv;
 8     }
 9 
10     public Test(int noSV) {
11         this.noStaticValue = noSV;
12     }
13 
14     interface valueHolder {
15         int getValue();
16     }
17 
18     class innerClass implements valueHolder {
19         public int getValue() {
20             return noStaticValue;
21         }
22     }
23 
24     static class nestClass implements valueHolder {
25         public nestClass(int i) {
26             staticValue = i;
27         }
28 
29         public int getValue() {
30             return staticValue;
31         }
32     }
33 
34     public static void main(String[] args) {
35         Test context1 = new Test(00);
36         valueHolder[] list = new valueHolder[10];
37         for (int i = 0; i < 10; i++) {
38             list[i] = new Test.nestClass(i);
39         }
40         for (valueHolder obj : list) {
41             System.out.println(obj.getValue());// always print 9
42         }
43         for (int i = 0; i < 10; i++) {
44             list[i] = new Test(i).new innerClass();
45         }
46         for (valueHolder obj : list) {
47             System.out.println(obj.getValue());// print 0-9
48         }
49     }
50 }
可見用inner class可以模擬closure的特性,就是運行時定義class的某些狀態。
inner class和nest class之間的區別就是后者是靜態類。前者必須通過wrap class的實例來調用new,e.g. new Test().new innerClass。
因為nest class是靜態類,所以可以添加static member 或者static method,而inner class 不行。
匿名內部類是inner class的一種特殊形式,所以也不能添加static member 或者static method。





sevenduan 2010-04-17 23:07 發表評論
]]>
String與byte轉化要小心失真http://www.tkk7.com/sevenduan/archive/2010/04/14/318378.htmlsevenduansevenduanWed, 14 Apr 2010 15:14:00 GMThttp://www.tkk7.com/sevenduan/archive/2010/04/14/318378.htmlhttp://www.tkk7.com/sevenduan/comments/318378.htmlhttp://www.tkk7.com/sevenduan/archive/2010/04/14/318378.html#Feedback0http://www.tkk7.com/sevenduan/comments/commentRss/318378.htmlhttp://www.tkk7.com/sevenduan/services/trackbacks/318378.html
byte [] b = new byte[]{1,-1,2,-2};
        System.out.println(Arrays.toString(
new String(b).getBytes()));

輸出:
[1, -17, -65, -67, 2, -17, -65, -67]
解釋:
byte decode to String,String encode to byte 默認用UTF-8 charset.
decode遇到不支持的字符 輸出 char ? , encode ? 就是 -17, -65, -67.
實現細節可見ByteToCharUTF8.java

解決辦法: 使用 ISO8859_1 charset。

教訓: 注意charset的范圍。





sevenduan 2010-04-14 23:14 發表評論
]]>
java 位運算http://www.tkk7.com/sevenduan/archive/2010/04/13/318160.htmlsevenduansevenduanTue, 13 Apr 2010 06:39:00 GMThttp://www.tkk7.com/sevenduan/archive/2010/04/13/318160.htmlhttp://www.tkk7.com/sevenduan/comments/318160.htmlhttp://www.tkk7.com/sevenduan/archive/2010/04/13/318160.html#Feedback0http://www.tkk7.com/sevenduan/comments/commentRss/318160.htmlhttp://www.tkk7.com/sevenduan/services/trackbacks/318160.html ~ The unary bitwise complement operator "~" inverts a bit pattern.
<<The signed left shift
>>The signed right shift
>>>the unsigned right shift

& The bitwise & operator performs a bitwise AND operation.

^ The bitwise ^ operator performs a bitwise exclusive OR operation.

| The bitwise | operator performs a bitwise inclusive OR operation.



Usage:
1,
  • ^ can swap two variables without using an intermediate, temporary variable which is useful if you are short on available RAM or want that sliver of extra speed.

    Usually, when not using ^, you will do:

    temp = a;

    a = b;

    b = temp;

    Using ^, no "temp" is needed:

    a ^= b;

    b ^= a;

    a ^= b;

    This will swap "a" and "b" integers. Both must be integers.

2,
an example of using an integer to maintain state flags (common usage):
// These are my masks

private static final int MASK_DID_HOMEWORK  = 0x0001;

private static final int MASK_ATE_DINNER    = 0x0002;

private static final int MASK_SLEPT_WELL    = 0x0004;



// This is my current state

private int m_nCurState;

To set my state, I use the bitwise OR operator:

// Set state for'ate dinner' and 'slept well' to 'on'

m_nCurState
= m_nCurState | (MASK_ATE_DINNER | MASK_SLEPT_WELL);

Notice how I 'or' my current state in with the states that I want to turn 'on'. Who knows what my current state is and I don't want to blow it away.

To unset my state, I use the bitwise AND operator with the complement operator:

// Turn off the 'ate dinner' flag

m_nCurState
= (m_nCurState & ~MASK_ATE_DINNER);

To check my current state, I use the AND operator:

// Check if I did my homework

if (0 != (m_nCurState & MASK_DID_HOMEWORK)) {

   
// yep

} else {

   
// nope...

}

Why do I think this is interesting? Say I'm designing an interface that sets my state. I could write a method that accepts three booleans:

void setState( boolean bDidHomework, boolean bAteDinner, boolean bSleptWell);

Or, I could use a single number to represent all three states and pass a single value:

void setState( int nStateBits);

If you choose the second pattern you'll be very happy when decide to add another state - you won't have to break existing impls of your interface.




sevenduan 2010-04-13 14:39 發表評論
]]>
JBossCache in JBoss Clusterhttp://www.tkk7.com/sevenduan/archive/2010/03/28/clustercache.htmlsevenduansevenduanSun, 28 Mar 2010 15:10:00 GMThttp://www.tkk7.com/sevenduan/archive/2010/03/28/clustercache.htmlhttp://www.tkk7.com/sevenduan/comments/316774.htmlhttp://www.tkk7.com/sevenduan/archive/2010/03/28/clustercache.html#Feedback0http://www.tkk7.com/sevenduan/comments/commentRss/316774.htmlhttp://www.tkk7.com/sevenduan/services/trackbacks/316774.html
Cache的目的是為了以空間換時間,一次計算結果為多次重用。
空間可以是實時內存空間、持久化的硬盤空間。時間可以是運算時間、連接時間、傳輸時間等。

Cache可以分為LocalCache和DistributedCache。
最簡單的LocalCache可以通過維護一個ConcurrentHashMap實現。
缺點是:
1,內存有限,容易out of memory (定期清除?持久化?)
2, 需要對全map做concurrency維護,粗粒度的鎖定爭用會影響性能(樹結構維護?)

在一個專業的企業級應用中,cache除了高性能和線程安全的要求,還要支持事務、高可用性、持久化、容錯、集群同步等。
JBossCache是一個典型的企業級cache實現,他采用樹結構且支持集群和事務特性。
雖然JBossCache這把牛刀也可以在standalone的JS2E應用中用來殺雞,但我們應該更關心用他在集群環境中怎么殺牛。
JBossCache分為非集群模式(Local)和集群模式。
集群模式根據實現策略又分為replication和invalidation。
1 replication:通過拷貝改變的cache對象來保證與集群中其他cache同步。replication又可細分為同步replication和異步repliation兩種,異步replication較快,put以后馬上返回,但是replication出錯了,事務還是算完成了不回回滾。同步replication要花時間等待其他的cache完成replication的通知才能結束。

2 invalidation: 如果cache狀態改變,僅僅是給其他cache發個通知,收到通知的cache把臟數據清除掉。invalidation也可分為同步和異步兩種,區別是發送通知的廣播方式一個是同步一個是異步。

在jboss cluster中,我們最好通過MBean來部署jboss cache。這樣又幾個好處:
1,JBoss NS支持Cluster
我們就可以通過JBoss NamingService來訪問cache。如果在local NS中查不到cache,jbss NS還會去查cluster中其他的cache。
2,利用MBean的特性
通過CacheMBean, 我們可以方便的管理Cache Service,實時的啟動、停止或者改變一些配置,還可以監控到一些cache統計數據。
3,利用microcontainer的特性
我們可以通過配置XML文件來完成cache相關的所有對象聲明。簡而言之,就是利用java reflection和AOP的技術就不用寫聲明cache的代碼了。


<?xml version="1.0" encoding="UTF-8"?>



<deployment xmlns="urn:jboss:bean-deployer:2.0">



   
<!-- First we create a Configuration object for the cache -->

   
<bean name="ExampleCacheConfig"

         class
="org.jboss.cache.config.Configuration">

      

       build up the Configuration

      

   
</bean>

   

   
<!-- Factory to build the Cache. -->

   
<bean name="DefaultCacheFactory" class="org.jboss.cache.DefaultCacheFactory">      

      
<constructor factoryClass="org.jboss.cache.DefaultCacheFactory"

                   factoryMethod
="getInstance" />

   
</bean>

   

   
<!-- The cache itself -->

   
<bean name="ExampleCache" class="org.jboss.cache.CacheImpl">

      

      
<constructor factoryMethod="createnewInstance">

          
<factory bean="DefaultCacheFactory"/>

          
<parameter><inject bean="ExampleCacheConfig"/></parameter>

          
<parameter>false</parameter>

      
</constructor>

          

   
</bean>

   

   
<!-- JMX Management -->

   
<bean name="ExampleCacheJmxWrapper" class="org.jboss.cache.jmx.CacheJmxWrapper">

      

      
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=ExampleTreeCache", 

                         exposedInterface=org.jboss.cache.jmx.CacheJmxWrapperMBean.class, 

                         registerDirectly=true)
</annotation>

      

      
<constructor>

          
<parameter><inject bean="ExampleCache"/></parameter>

      
</constructor>

          

   
</bean>



</deployment> 

后記:
1,jboss cache的naga版中,采用Multi-versioned concurrency control來實現并發。下次再從中總結一下多線程的學習。
2,jboss cache通過結合visitor pattern和command pattern,把對cache node的操作與訪問從中隔離出來,不用改變或者擴展node對象就可以添加新的node行為。也就是開閉原則。下次再從中總結一下幾種設計模式的經典應用。





sevenduan 2010-03-28 23:10 發表評論
]]>
Use Annotation or not in javahttp://www.tkk7.com/sevenduan/archive/2010/01/04/308154.htmlsevenduansevenduanMon, 04 Jan 2010 03:28:00 GMThttp://www.tkk7.com/sevenduan/archive/2010/01/04/308154.htmlhttp://www.tkk7.com/sevenduan/comments/308154.htmlhttp://www.tkk7.com/sevenduan/archive/2010/01/04/308154.html#Feedback0http://www.tkk7.com/sevenduan/comments/commentRss/308154.htmlhttp://www.tkk7.com/sevenduan/services/trackbacks/308154.html Pros and Cons:

Pros:

1, reduce configuration xml files

2, readable by self-documenting

Cons:

1, it adds deployment context to classes, which should be generic enough.

2, interfere with design principles such as IOC and dependency injection, because you need to introduce imports

Usage (annotation works only when handled by related annotation processor):

  • Information for the compiler — Annotations can be used by the compiler to detect errors or suppress warnings.
  • Compiler-time and deployment-time processing — Software tools can process annotation information to generate code, XML files, and so forth.
  • Runtime processing — Some annotations are available to be examined at runtime.

  1 import java.io.IOException;
  2 import java.io.PrintStream;
  3 import java.lang.reflect.AnnotatedElement;
  4 import java.lang.annotation.Annotation;
  5 
  6 import java.util.Date;
  7 import java.lang.annotation.Documented;
  8 import java.lang.annotation.Inherited;
  9 import java.lang.annotation.Retention;
 10 import java.lang.annotation.RetentionPolicy;
 11 
 12 public class ReflectionTester {
 13 
 14   public ReflectionTester() {
 15   }
 16 
 17   public void testAnnotationPresent(PrintStream out) throws IOException {
 18     Class c = Super.class;
 19     boolean inProgress = c.isAnnotationPresent(InProgress.class);
 20     if (inProgress) {
 21       out.println("Super is In Progress");
 22     } else {
 23       out.println("Super is not In Progress");
 24     }
 25   }
 26 
 27   public void testInheritedAnnotation(PrintStream out) throws IOException {
 28     Class c = Sub.class;
 29     boolean inProgress = c.isAnnotationPresent(InProgress.class);
 30     if (inProgress) {
 31       out.println("Sub is In Progress");
 32     } else {
 33       out.println("Sub is not In Progress");
 34     }
 35   }
 36 
 37   public void testGetAnnotation(PrintStream out) 
 38     throws IOException, NoSuchMethodException {
 39 
 40     Class c = AnnotationTester.class;
 41     AnnotatedElement element = c.getMethod("calculateInterest"
 42                                   float.classfloat.class);
 43 
 44     GroupTODO groupTodo = element.getAnnotation(GroupTODO.class);
 45     String assignedTo = groupTodo.assignedTo();
 46 
 47     out.println("TODO Item on Annotation Tester is assigned to: '" + 
 48         assignedTo + "'");
 49   }
 50 
 51   public void printAnnotations(AnnotatedElement e, PrintStream out)
 52     throws IOException {
 53 
 54     out.printf("Printing annotations for '%s'%n%n", e.toString());
 55 
 56     Annotation[] annotations = e.getAnnotations();
 57     for (Annotation a : annotations) {
 58       out.printf("    * Annotation '%s' found%n"
 59         a.annotationType().getName());
 60     }
 61   }
 62 
 63   public static void main(String[] args) {
 64     try {
 65       ReflectionTester tester = new ReflectionTester();
 66 
 67       tester.testAnnotationPresent(System.out);
 68       tester.testInheritedAnnotation(System.out);
 69 
 70       tester.testGetAnnotation(System.out);
 71 
 72       Class c = AnnotationTester.class;
 73       AnnotatedElement element = c.getMethod("calculateInterest"
 74                                     float.classfloat.class);      
 75       tester.printAnnotations(element, System.out);
 76     } catch (Exception e) {
 77       e.printStackTrace();
 78     } 
 79   }
 80 }
 81 
 82 class Sub extends Super {
 83 
 84   public void print(PrintStream out) throws IOException {
 85     out.println("Sub printing");
 86   }
 87 }
 88 
 89 @InProgress class Super {
 90 
 91   public void print(PrintStream out) throws IOException {
 92     out.println("Super printing");
 93   }
 94 }
 95 
 96 @Documented
 97 @Retention(RetentionPolicy.RUNTIME)
 98 @interface GroupTODO {
 99 
100   public enum Severity { CRITICAL, IMPORTANT, TRIVIAL, DOCUMENTATION };
101 
102   Severity severity() default Severity.IMPORTANT;
103   String item();
104   String assignedTo();
105   String dateAssigned();
106 }
107 
108 /**
109  * Marker annotation to indicate that a method or class
110  *   is still in progress.
111  */
112 @Documented
113 @Inherited
114 @Retention(RetentionPolicy.RUNTIME)
115 @interface InProgress { }
116 
117 class AnnotationTester {
118 
119   @InProgress
120   @GroupTODO(
121     severity=GroupTODO.Severity.CRITICAL,
122     item="Figure out the amount of interest per month",
123     assignedTo="Brett McLaughlin",
124     dateAssigned="04-26-2004"
125   )
126   public void calculateInterest(float amount, float rate) {
127     // Need to finish this method later
128   }
129 }
130 


sevenduan 2010-01-04 11:28 發表評論
]]>
JSF + DWR + Json Practicehttp://www.tkk7.com/sevenduan/archive/2010/01/04/308127.htmlsevenduansevenduanMon, 04 Jan 2010 00:58:00 GMThttp://www.tkk7.com/sevenduan/archive/2010/01/04/308127.htmlhttp://www.tkk7.com/sevenduan/comments/308127.htmlhttp://www.tkk7.com/sevenduan/archive/2010/01/04/308127.html#Feedback0http://www.tkk7.com/sevenduan/comments/commentRss/308127.htmlhttp://www.tkk7.com/sevenduan/services/trackbacks/308127.html JSF:  MVC framework as Struts
DWR: java Ajax framework
Json: a data format definition like XML, YAML. We could use DWR or jsonlib to marshal/unmarshal between json and objects.

How to use?
1, when should we use json or not?
do JSF as much as possible;
only when dynamic collection size on page, do Json
2, when should we use DWR json convertor configuration or customize json convertor by java?
page scope update, do Ajax by DWR as much as possible;
otherwise, do JSF action by json convertor (consolidate convertor by jsonlib or dwr?)


DWR convertor VS Jsonlib convertor:
    DWR:
    convertor setting by xml, annotation or java;

    Jsonlib:
    convertor setting by java (only check @Transient), but more professional overall;

Requirement:
1, simple convertion, no VO or DTO:
    PO to json: 1, cycle detect; 2,include/exclude;
    Json to PO: 1, the same js handle; 2, ajax by dwr; jsf by hidden string
2, one PO map into two JSON model for different domains (e.g. bind different convertor by spring to different domain serviceImpl)

Not to do list:
1, do not use duplicated convertors definition in java/xml/annotation
2, do not DTO or VO when convert between json and objects
3, do not parse or transfer useless fields, e.g. use include / exclude configuration instead during convert objects into json; use "delete" during convert json into object
4, do not use json if could use JSF



sevenduan 2010-01-04 08:58 發表評論
]]>
java collections, Dictionary and Map Summaryhttp://www.tkk7.com/sevenduan/archive/2009/12/21/306859.htmlsevenduansevenduanMon, 21 Dec 2009 15:04:00 GMThttp://www.tkk7.com/sevenduan/archive/2009/12/21/306859.htmlhttp://www.tkk7.com/sevenduan/comments/306859.htmlhttp://www.tkk7.com/sevenduan/archive/2009/12/21/306859.html#Feedback0http://www.tkk7.com/sevenduan/comments/commentRss/306859.htmlhttp://www.tkk7.com/sevenduan/services/trackbacks/306859.html     boolean contains(Object o):return true only if has (o==null ? e==null :o.equals(e))
    boolean removeAll(Collection<?> c); remove elements in c
    boolean retainAll(Collection<?> c); remove elements not in c
    Queue VS List VS Set
    List>
        ListIterator<E> listIterator();| Iterator<E> iterator();
        next() & previous()|only has next()
        add() & remove()|only has remove()
        * you can not use list.add() during both two iteration, otherwise,ConcurrentModificationException

RandomAccess>
        Marker interface used by List implementations to indicate that they support fast (generally constant time) random access. e.g.
        for (int i=0, n=list.size(); i < n; i++)
                 list.get(i);
        runs faster than this loop:
             for (Iterator i=list.iterator(); i.hasNext(); )
                 i.next();

HashMap, HashSet, HashTable>
    HashMap(int initialCapacity, float loadFactor)        resize()
    HashSet(int initialCapacity, float loadFactor) {map = new HashMap<E,Object>(initialCapacity, loadFactor);}
    Hashtable(int initialCapacity, float loadFactor) extends Dictionary<K,V>  ; synchronized ;  rehash();
    hash = hash(key.hashCode());
    *TreeMap Red-black mechanics


sevenduan 2009-12-21 23:04 發表評論
]]>
java.lang.String hidden features Summaryhttp://www.tkk7.com/sevenduan/archive/2009/12/21/java.htmlsevenduansevenduanMon, 21 Dec 2009 14:36:00 GMThttp://www.tkk7.com/sevenduan/archive/2009/12/21/java.htmlhttp://www.tkk7.com/sevenduan/comments/306855.htmlhttp://www.tkk7.com/sevenduan/archive/2009/12/21/java.html#Feedback0http://www.tkk7.com/sevenduan/comments/commentRss/306855.htmlhttp://www.tkk7.com/sevenduan/services/trackbacks/306855.html     String|StringBuffer|StringBuilder
    immutable|mutable|mutable  <-- depends on the char[] value is final or not;
    thread-safe|thread-safe|single thread

1, compile phase:
    constance will be directly written. OuerClass.constance not refer to it during runtime.
    + =after compiled=> StringBuilder

2, Performance:
    usually, StringBuilder>StringBuffer>+; but need  to make sure the real generated class file.
    String.intern() is better if too many duplicated string instance.

3, String <--> bytes
decode: String(byte bytes[], int offset, int length, Charset charset)
encode: String.getBytes(Charset charset)

4, StringTokenizer | String.split
    better performance | RegEx


sevenduan 2009-12-21 22:36 發表評論
]]>
主站蜘蛛池模板: 日韩免费高清播放器| 无套内射无矿码免费看黄 | 亚洲欧美中文日韩视频| 免费观看激色视频网站bd| 在线观看亚洲人成网站| 中文字幕免费在线| 亚洲日本乱码一区二区在线二产线 | 亚洲人成网站色在线观看| 67194熟妇在线永久免费观看 | 国产在线jyzzjyzz免费麻豆| 337p日本欧洲亚洲大胆艺术| 日韩精品免费一级视频| 亚洲人成网站日本片| 免费观看的av毛片的网站| 色偷偷尼玛图亚洲综合| 亚洲免费一区二区| 可以免费观看的毛片| 77777_亚洲午夜久久多人| 在线不卡免费视频| 免费一级全黄少妇性色生活片 | 日韩亚洲国产高清免费视频| 亚洲综合激情五月色一区| 成人免费视频国产| 国产乱妇高清无乱码免费| 婷婷精品国产亚洲AV麻豆不片| 最近免费视频中文字幕大全| 亚洲女女女同性video| 亚洲日本中文字幕一区二区三区| 花蝴蝶免费视频在线观看高清版 | 日本免费网址大全在线观看| 亚洲精品无码mⅴ在线观看| 亚洲欧洲精品成人久久奇米网 | 久久久久亚洲精品日久生情 | 男女啪啪免费体验区| 亚洲av伊人久久综合密臀性色| 亚洲免费一区二区| 99视频在线免费看| 日韩亚洲一区二区三区| 2019中文字幕在线电影免费| 色婷婷精品免费视频| 亚洲最新视频在线观看|