6월 26일 간단한 캐시 예

971 단어 캐시
/**
 *      
 * */
public class ProJava {
    //    Map     
    private static Map<Integer,Object> map = new HashMap<Integer, Object>();
    //    ,   ,    
    static{
        //        
        init();
    }
    //     map 
    public static void init(){
        for(int i=0;i <9;i++){
            map.put(i,i+"  ");
        }
    }
    //    key     
    public static Object get(Integer key){
        //key   null ,    
        if(key != null){
            return map.get(key);
        }
        return map;
    }
}

 
/**
 *     
 * */
public class Test {
    public static void main(String[] args){
        //  key 1 value 
        System.out.println(ProJava.get(1));
    }
}

안녕하세요

좋은 웹페이지 즐겨찾기