導航:首頁 > 編程語言 > java統計

java統計

發布時間:2022-02-09 05:30:20

java 如何統計一分鍾的數據

可以在循環之前添加一句取時間的,循環之後再取一次,然後計算他們的差值就是100000次的時間

㈡ java中怎麼統計輸入的次數

總體思路,定義一個靜態全局變數來統計方法執行次數,每進方法一次,統計次數加1
所有方法執行完成時,輸出統計次數就可以了。
示例代碼如下:
public class CountTest {
public static int count1 = 0;
public static int count2 = 0;
public static void main(String[] args) {
Random r = new Random();
for (int i=0; i < 10; i++) {
int num = r.nextInt();
if (num > 0.5) {
method1();
} else {
method2();
}
}

System.out.println(count1 + " " + count2);
}

public static void method1() {

㈢ java統計行數 幫幫忙~~謝謝了

public class CodeCounter {

static long normalLines = 0;
static long commentLines = 0;
static long whiteLines = 0;

public static void main(String[] args) {
File f = new File("D:\\share\\JavaProjects\\TankWar1.9.11\\src");
File[] codeFiles = f.listFiles();
for(File child : codeFiles){
if(child.getName().matches(".*\\.java$")) {
parse(child);
}
}

System.out.println("java代碼:" + normalLines);
System.out.println("注釋行:" + commentLines);
System.out.println("空白行:" + whiteLines);

}

private static void parse(File f) {
BufferedReader br = null;
boolean comment = false;
try {
br = new BufferedReader(new FileReader(f));
String line = "";
while((line = br.readLine()) != null) {
line = line.trim();
if(line.matches("^[\\s&&[^\\n]]*$")) {
whiteLines ++;
} else if (line.startsWith("/*") && !line.endsWith("*/")) {
commentLines ++;
comment = true;
} else if (line.startsWith("/*") && line.endsWith("*/")) {
commentLines ++;
} else if (true == comment) {
commentLines ++;
if(line.endsWith("*/")) {
comment = false;
}
} else if (line.startsWith("//")) {
commentLines ++;
} else {
normalLines ++;
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if(br != null) {
try {
br.close();
br = null;
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

}

㈣ java 實現報表統計

java本身沒有操作excel的工具,需要第三方的jar包,用jxl就可以,代碼入下。
jxl你上網路搜索後下載就可以,簡單易用,不懂追問。
public boolean exportExcel(HttpServletResponse response,List<cityinfo> list)
{
try
{
OutputStream os = response.getOutputStream();// 取得輸出流
response.reset();// 清空輸出流
response.setHeader("Content-disposition", "attachment; filename=fine.xls");// 設定輸出文件頭
response.setContentType("application/msexcel");// 定義輸出類型

WritableWorkbook wbook = Workbook.createWorkbook(os); // 建立excel文件
String tmptitle = "標題"; // 標題
WritableSheet wsheet = wbook.createSheet("詳細信息表", 0); // sheet名稱
WritableSheet wsheet = wbook.createSheet("性別統計表", 1); // sheet名稱
WritableSheet wsheet = wbook.createSheet("證件類型統計表", 2); // sheet名稱

// 設置excel標題
WritableFont wfont = new WritableFont(WritableFont.ARIAL, 16,WritableFont.BOLD,
false,UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
WritableCellFormat wcfFC = new WritableCellFormat(wfont);
wcfFC.setBackground(Colour.AQUA);
wsheet.addCell(new Label(1, 0, tmptitle, wcfFC));
wfont = new jxl.write.WritableFont(WritableFont.ARIAL, 14,WritableFont.BOLD,
false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
wcfFC = new WritableCellFormat(wfont);

// 開始生成主體內容
wsheet.addCell(new Label(0, 2, "具體內容"));

for(int i=0;i<list.size();i++) <br="">{
wsheet.addCell(new Label(0, i+3, "");
wsheet.addCell(new Label(1, i+3,"");

}
// 主體內容生成結束
wbook.write(); // 寫入文件
wbook.close();
os.close(); // 關閉流
return true;
}
catch(Exception ex)
{
ex.printStackTrace();
return false;
}
}

㈤ java數據統計怎麼做

你的問題還真是具體啊~~~~~~
不知道你問的是什麼東西,如果用容器的話vector、hashmap什麼的都可以
給你一個例子:
Vector<String> myVector = new Vector<String>();
myVector.add("example");
這就是最簡單的應用hashmap不過是多了個建值而已
有什麼不懂的可以hi我

㈥ Java如何進行資料庫里的數據統計

你這個跟java沒什麼關系,資料庫自己就能實現。
T-SQL這樣寫就可以了

select * into table2 from table1
where (time>3:00 and time<5:00) --這句是偽代碼,你把條件改對

如果要統計數據條數,另寫一條sql查。
如果table2已經建好,請先刪除。
-------------------------------------------------------
這還不簡單啊,把上面的內容組合一下。

select count(*) as count_num from table1 where (你的條件)
--這句得到數據條數了。
再加上這句
select no,time from table1 where (你的條件)
--這句得到所有符合條件的數據。

插入也可以用子查詢
--假設table2的id是自增的
insert into table2(no,time) values(
select no,time from table1 where(你的條件)
)

你在java里通過這些查詢已經得到你要的數據了,再處理下就行了。
也可以把所有的查詢都變成子查詢然後放到一個SQL語句裡面,不過好象沒必要。

㈦ Java數據統計

如果用容器的話vector、hashmap什麼的都可以
給你一個例子:
Vector<String> myVector = new Vector<String>();
myVector.add("example");
這就是最簡單的應用hashmap不過是多了個建值而已

㈧ Java 統計

select webname,web_count from tbl limit 1,9 order by web_count
unoin all
select '其他' as webname, tmp.web_count from (select * from tbl limit 10,1 order by web_count) tmp

㈨ java統計單詞的個數

import java.util.Scanner;

public class Test40031 {
public static void main(String []args ){
int ri, repeat,count, word,i;
String line;
char c;
Scanner in=new Scanner(System.in);
repeat=(in.nextLine()).charAt(0)-'0'; //輸入repeat
for(ri=1; ri<=repeat; ri++){
line=in.nextLine(); //輸入一行字元
/*---------*/
count=Count(line);
System.out.println(count);
}
}
public static int Count(String str){
String[] str1=str.split(" ");
int count=str1.length;
return count;
}
}

㈩ Java的數據統計

開局一張圖,問題都不說

閱讀全文

與java統計相關的資料

熱點內容
雲伺服器關機網址不見了 瀏覽:69
余冠英pdf 瀏覽:755
開發一個app上市需要什麼步驟 瀏覽:28
phpsleep方法 瀏覽:430
時間同步伺服器ip地址6 瀏覽:926
鋼琴譜pdf下載 瀏覽:524
香港阿里雲伺服器怎麼封udp 瀏覽:875
APp買海鮮到哪裡 瀏覽:501
遼油社保app總提示更新怎麼辦 瀏覽:586
導入源碼教程視頻 瀏覽:613
天翼貸app在哪裡下載 瀏覽:186
app開發源碼查看器 瀏覽:516
程序員發展到了一個瓶頸 瀏覽:120
程序員去機房幹嘛 瀏覽:697
英雄訓練師怎麼看曾經伺服器 瀏覽:546
魔獸世界單機輸入gm命令 瀏覽:372
51單片機最大負跳距是多少 瀏覽:418
android聊天控制項 瀏覽:128
導致壓縮機壞的原因 瀏覽:295
如何多次選取文件夾 瀏覽:280