首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

面试题:大家都来解答吧解决方法

2012-04-18 
面试题:大家都来解答吧1、字符串的最大长度2简述单子模式在系统中的作用,并且举例说明3 简述Ajax的工作原理

面试题:大家都来解答吧
1、字符串的最大长度
 2简述单子模式在系统中的作用,并且举例说明
 3 简述Ajax的工作原理
 4简述struts,hibernate,spring在系统中充当的角色
(二)分析题目:
 1、如下程序:public void isBoolean(String names[])(10)
{
for(String name:names)
{
System.out.println(name);
}
}
在weblogic8.0下执行错误。请问错在哪里。需要如何修改。

2 写一个程序统计C盘中各个类型文件的个数?



[解决办法]
二,1)增强for循环是JDK5.0的新特征,改为普通for循环
[解决办法]
2 写一个程序统计C盘中各个类型文件的个数?

Java code
public static void main(String[] args) throws Exception    {        Map<String,Integer> map = new HashMap<String,Integer>();        searchFile(map,new File("e:"));                Set set = map.entrySet();        for(Iterator i = set.iterator();i.hasNext();)        {            Map.Entry<String, Integer> temp = (Map.Entry<String, Integer>)i.next();            System.out.println(temp.getKey() + ":" + temp.getValue());        }    }    public static void searchFile(Map map,File file) throws Exception    {        if(file.isFile())        {            if(file.getName().lastIndexOf(".") != -1)            {                String fileName = file.getName().toLowerCase();                String suffix = fileName.substring(fileName.lastIndexOf(".")+1,fileName.length());                if(map.containsKey(suffix))                {                    map.put(suffix, Integer.parseInt(map.get(suffix).toString()) + 1);                }                else                {                    map.put(suffix, 1);                }            }                    }        else        {            File[] files = file.listFiles();            for(File tempFile:files)            {                searchFile(map,tempFile);            }        }    } 

热点排行