有 81 筆資料符合您搜尋的條件
- 2017年 10月 8日, 21:47
- 版面: 執行緒與並行 API
- 主題: Java多執行緒程式設計
- 回覆: 0
- 觀看: 14062
Java多執行緒程式設計
請參考這裡[分享]Java多執行緒程式設計
- 2017年 10月 8日, 21:45
- 版面: Java SE7
- 主題: Java多執行緒程式設計
- 回覆: 0
- 觀看: 13941
java.lang.StringBuilder & StringBuffer
非多執行緒 (Multithread), 使用 StringBuilder 有較好的效率。
StringBuilder
不處理 Synchronized;
StringBuffer
會處理 Synchronized,多執行緒環境下使用。
StringBuilder
不處理 Synchronized;
StringBuffer
會處理 Synchronized,多執行緒環境下使用。
1+2+...+100
Method1 for(int i = 1; i < 101; i++) { System.out.print(i); if(i != 100) { System.out.print('+'); } } Method2 for(int i = 1; i < 100; i++) { System.out.printf("%d+",i); } System.out.println(100); Method3 String text = ""; for(int i = 1; i < 100; i++) { text = text + i + '+'; } System.out.println(te...
- 2014年 8月 18日, 15:49
- 版面: Java SE7
- 主題: Astah for Project Flow Chart
- 回覆: 0
- 觀看: 9243
Astah for Project Flow Chart
http://davidlan.synology.me/ProjectFlowChart.png RCA : Root Cause Analysis RCA report的撰寫規則如下,細節請見附件的描述。 http://davidlan.synology.me/RCAreport.png Symptom: You can watch or feel directly without any analysis Real Fault: Which part (SW&HW) with what problem cause the symptom Root Cause: Who (User, Su...
不可變動字串 (Immutable)
字串物件一旦建立,物件上沒有任何方法可以更動字串內容。
Original
String name1 = "Java";
String name2 = name1 + "World"
Decompile
String s = "Java";
String s1 = (new StringBuilder()).append(s)("World").toString();
使用+串接字串會產生新的 String 實例,不要將 + 用在重複性的串接場合,會有效能上的負擔。
Original
String name1 = "Java";
String name2 = name1 + "World"
Decompile
String s = "Java";
String s1 = (new StringBuilder()).append(s)("World").toString();
使用+串接字串會產生新的 String 實例,不要將 + 用在重複性的串接場合,會有效能上的負擔。
- 2014年 8月 11日, 17:59
- 版面: 物件
- 主題: Array Copy
- 回覆: 1
- 觀看: 10913
Re: Array Copy
Deep Copy (得自行實作,每個物件都得 copy)
- 2014年 8月 11日, 17:54
- 版面: 物件
- 主題: Array Copy
- 回覆: 1
- 觀看: 10913
Array Copy
<p.4-30, Java SE7>
Shallow Copy (並未實際 copy Array 內的每個物件)
1.
int[] scores1 = {...};
int[] scores2 = scores1;
2.
System.arraycopy(scores1,0,scores2,0, scores1.length);
3.
int[] scores2 = Arrays.copyOf(scores1, length); (length 超過 scores1.length 時,預設值為0)
Shallow Copy (並未實際 copy Array 內的每個物件)
1.
int[] scores1 = {...};
int[] scores2 = scores1;
2.
System.arraycopy(scores1,0,scores2,0, scores1.length);
3.
int[] scores2 = Arrays.copyOf(scores1, length); (length 超過 scores1.length 時,預設值為0)
- 2014年 8月 11日, 12:09
- 版面: 基礎語法
- 主題: 三位數的 Armstrong 數
- 回覆: 0
- 觀看: 6360
三位數的 Armstrong 數
public class Exercise3_2 { public static void main(String[] args) { for(int i = 100; i < 1000; i++) { if (Math.pow(i / 100, 3) + Math.pow((i % 100) / 10, 3) + Math.pow(i % 10, 3) == i) { System.out.println(Math.pow(i / 100, 3)); System.out.println(Math.pow(i % 100, 3)); System.out.println(Math.pow(i...
- 2014年 8月 11日, 12:02
- 版面: 基礎語法
- 主題: 輾轉相除法求最大公因式
- 回覆: 1
- 觀看: 10180
輾轉相除法求最大公因式
Method2 public class Exercise3_1 { public static int gcd(int m, int n) { return n == 0 ? m : gcd(n, m % n); } public static int lcm(int m, int n) { return m * n / gcd(m, n); } public static void main(String[] args) { int p = 1000; int q = 495; System.out.printf("gcd(%d, %d) = %d%n", p, q, gcd(p, q))...