请教:Set<Character> set= new HashSet<Character>();
 
如何将  11,12,AA  加入到set中   

解决方案 »

  1.   

    转化成字符添加进去?
    只能将11和12,还有AA转化成对应的char然后添加进去。但是这个AA
      

  2.   

    好像除了转换也没其他好的方法了,本人能力有限。Set<Character> set= new HashSet<Character>();
    String multiString = "aa"+"11"+"AA";
    for(Character c:multiString.toCharArray())
    {
    set.add(c);
    }不过这样的set感觉很浪费 还不如用数组呢
      

  3.   

    /**
     * 创建 Criteria 信息
     * 
     * @param <T>
     * @param entity
     * @return
     */
    public <T> Criteria createCriteria(Class<T> entity) { try {
    Session session = null;
    session = getHibernateTemplate().getSessionFactory().openSession(); if (!session.isOpen()) {
    logger.error("Error : the session is closed");
    }
    return session.createCriteria(entity);
    } catch (Exception se) {
    logger.error("Error :" + se.getMessage());
    }
    return null; }
      

  4.   

    5楼7楼在刷屏!哈哈Set<Character> set= new HashSet<Character>();
     
    如何将 11,12,AA 加入到set中11,12,AA都不是Character类型啊,怎么可能加入!
    可以改成String啊,或者String的父类
    Set<String> set= new HashSet<String>();
    set.add("11").add("12").add("AA");
      

  5.   


    public static void main(String[] args) { Set<Character> set= new HashSet<Character>();
    String[] array={"11","12","AA"};
    for(String s:array){
    int temp=Integer.parseInt(s,16);
    set.add((char)temp);
    }
    for(Character c:set){
    System.out.println(Integer.toHexString((int)c).toUpperCase());
    } }
      

  6.   

    package com.xuz.csdn.worldcup.day12;import java.util.HashSet;
    import java.util.Set;public class CharsetTest { public static void main(String[] args) {
    Set<Character> set= new HashSet<Character>();
    set.add((char)11);
    set.add((char)12);

    System.out.println(set);
    }}
    AA不会了,不知道你有什么要求。