String temp;
int count=0;
int countSpace=0;
int countCode=0;
int countDesc=0;
MapString, Integer map = getKeyWords();
while((temp=br.readLine())!=null){
countKeys(temp, map);
count++;
if(temp.trim().equals("")){
countSpace++;
}else if(temp.trim().startsWith("/*")||temp.trim().startsWith("//")){
countDesc++;
}else{
countCode++;
}
}
System.out.printf("代码行数:"+countCode+"占总行数的%4.2f\n",(double)countCode/count);
System.out.printf("空行数:"+countSpace+"占总行数的%4.2f\n",(double)countSpace/count);
System.out.printf("注释行数:"+countDesc+"占总行数的%4.2f\n",(double)countDesc/count);
System.out.println("总行数:"+count);
System.out.println("出现最多的5个关键字是:");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
}
public static void main(String[] args) {
getKeyWords();
File file = new File("F://Test.java");
try {
analyze(file);
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
public static MapString,Integer getKeyWords(){
MapString,Integer map = new HashMapString, Integer();
String[]keywords = {"abstract","assert","boolean","break","byte","case","catch","char","class","continue","default","do","double","else","enum","extends","final","finally","float","for","if","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","return","strictfp","short","static","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while","goto","const"};
for(String s:keywords){
map.put(s, 0);
}
return map;
【java代码怎么分析 java代码怎么看懂】}
public static void countKeys(String s,MapString,Integer map){
SetString keys = map.keySet();
for(String ss:keys){
if(s.indexOf(ss)!=-1){
map.put(ss, map.get(ss)+1);
}
}
}
}
上班没啥时间了,还有点没写完,你在想想 。
java代码怎么分析的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java代码怎么看懂、java代码怎么分析的信息别忘了在本站进行查找喔 。
推荐阅读
- 家用椅子直播卖货可以吗,直播椅子怎么安装
- 电脑怎么筛选分类照片文件,电脑怎么筛选文件类型
- 我的世界国外服务器加速器,我的世界国外服务器加速器推荐
- 直播视频号文案,直播视频文案的写作技巧有哪些
- 社团网java代码 社团管理系统源码
- 阿里云git服务器,阿里云 git
- 直播睡眠工具设备全套,主播助睡眠在哪里直播
- python3初始化函数的简单介绍
- 拍摄什么设备收音好,手机拍摄用什么收音设备