
正文
java代码显示行数 java如何显示行数
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
java eclipse如何显示行数
1. 在左边边框旁java代码显示行数,点击鼠标右键, 有一个show Line Numbers. 点击就可以java代码显示行数了。
2. ctrl+F可以查找
3. 点击工程java代码显示行数,有一个Refactor有一个rename可以重命名
相关问答
Q1: 中文版java eclipse如何显示行数
"和英文版的位置一样,菜单大致是 窗口--引用,打开引用窗口,点击“通用”--编辑器 --文本编辑器,右侧有一列复选框,其中有一个是显示行号,在前面打√,确定就好了
Q2: 一个java类标准代码行数范围大概是多少
以1000行为准,超过千行就要考虑类拆分了。
类的代码行数没有特定的行数限制规范。根据实际情况决定。
对于经常使用的java类,代码行数应该尽可能的少,这样能减少java类的加载时间,减少内存频繁占用和回收。如果类过大,java类加载会耗时并且占用内存大。容易引起内存回收。
Q3: java问题,在后台如何获取前台table里显示数据的行数?
使用JS代码 var i = document.getElementById("project").rows.lengthjava代码显示行数; 这个就能够获取到table的行数java代码显示行数,project是table的id属性的值java代码显示行数,你在挑战的时候把参数i带上就可以了
Q4: Java 有什么好的代码行数,注释行数统计工具
package com.syl.demo.test;
import java.io.*;
/**
* java代码行数统计工具类
* Created by 孙义朗 on 2017/11/17 0017.
*/
public class CountCodeLineUtil {
private static int normalLines = 0; //有效程序行数
private static int whiteLines = 0; //空白行数
private static int commentLines = 0; //注释行数
public static void countCodeLine(File file) {
System.out.println("代码行数统计java代码显示行数:" + file.getAbsolutePath());
if (file.exists()) {
try {
scanFile(file);
} catch (IOException e) {
e.printStackTrace();
}
} else {
System.out.println("文件不存在java代码显示行数!");
System.exit(0);
}
System.out.println(file.getAbsolutePath() + " ,java文件统计java代码显示行数:" +
"总有效代码行数: " + normalLines +
" ,总空白行数:" + whiteLines +
" ,总注释行数:" + commentLines +
" ,总行数:" + (normalLines + whiteLines + commentLines));
}
private static void scanFile(File file) throws IOException {
if (file.isDirectory()) {
File[] files = file.listFiles();
for (int i = 0; i files.length; i++) {
scanFile(files[i]);
}
}
if (file.isFile()) {
if (file.getName().endsWith(".java")) {
count(file);
}
}
}
private static void count(File file) {
BufferedReader br = null;
// 判断此行是否为注释行
boolean comment = false;
int temp_whiteLines = 0;
int temp_commentLines = 0;
int temp_normalLines = 0;
try {
br = new BufferedReader(new FileReader(file));
String line = "";
while ((line = br.readLine()) != null) {
line = line.trim();
if (line.matches("^[//s[^//n]]*$")) {
// 空行
whiteLines++;
temp_whiteLines++;
} else if (line.startsWith("/*") !line.endsWith("*/")) {
// 判断此行为"/*"开头java代码显示行数的注释行
commentLines++;
comment = true;
} else if (comment == true !line.endsWith("*/")) {
// 为多行注释中java代码显示行数的一行(不是开头和结尾)
commentLines++;
temp_commentLines++;
} else if (comment == true line.endsWith("*/")) {
// 为多行注释的结束行
commentLines++;
temp_commentLines++;
comment = false;
} else if (line.startsWith("//")) {
// 单行注释行
commentLines++;
temp_commentLines++;
} else {
// 正常代码行
normalLines++;
temp_normalLines++;
}
}
System.out.println(file.getName() +
" ,有效行数" + temp_normalLines +
" ,空白行数" + temp_whiteLines +
" ,注释行数" + temp_commentLines +
" ,总行数" + (temp_normalLines + temp_whiteLines + temp_commentLines));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
br = null;
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
//测试
public static void main(String[] args) {
File file = new File("F:\\myweb");
countCodeLine(file);
}
}
关于java代码显示行数和java如何显示行数的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。







