public interface IK { class V{ 
  


比如像上面的定义形式,在真实的设计用有什么用武之地,谢谢 

解决方案 »

  1.   

    应该有意义吧
    假如接口IK只是针对某种数据结构V进行操作,其他类有可能不会再用到V了,那么把V作为IK的内部类,层次管理也方便吧,就像Map和Map.Entry一样吧
      

  2.   

    这是java.util.Map接口的源码。
    接口里定义了一个Entry接口,看看这个东东是怎么用的,或许对你有启发。
    java源码
    http://www.docjar.com/html/api/java/util/Map.java.html
    1 /*
    2  * Copyright 2006 Google Inc.
    3  * 
    4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
    5  * use this file except in compliance with the License. You may obtain a copy of
    6  * the License at
    7  * 
    8  * http://www.apache.org/licenses/LICENSE-2.0
    9  * 
    10  * Unless required by applicable law or agreed to in writing, software
    11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    13  * License for the specific language governing permissions and limitations under
    14  * the License.
    15  */
    16 package java.util;
    17 
    18 /**
    19  * Abstract interface for maps.
    20  */
    21 public interface Map {
    22 
    23   /**
    24    * Represents an individual map entry.
    25    */
    26   public static interface Entry {
    27     boolean equals(Object   o);
    28 
    29     Object   getKey();
    30 
    31     Object   getValue();
    32 
    33     int hashCode();
    34 
    35     Object   setValue(Object   value);
    36   }
    37 
    38   void clear();
    39 
    40   boolean containsKey(Object   key);
    41 
    42   boolean containsValue(Object   value);
    43 
    44   Set   entrySet();
    45 
    46   boolean equals(Object   o);
    47 
    48   Object   get(Object   key);
    49 
    50   int hashCode();
    51 
    52   boolean isEmpty();
    53 
    54   Set   keySet();
    55 
    56   Object   put(Object   key, Object   value);
    57 
    58   void putAll(Map   t);
    59 
    60   Object   remove(Object   key);
    61 
    62   int size();
    63 
    64   Collection   values();
    65 }Read more: http://kickjava.com/src/java/util/Map.java.htm#ixzz1AsVdhaPQ