<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4453668544708709700</id><updated>2026-09-15T18:38:36.349+08:00</updated><category term="Java-JAVA"/><category term="Android-adroid"/><category term="C-c"/><category term="Java-集合"/><category term="Linux-linux"/><category term="Gps-gps"/><category term="c"/><category term="Java-IO"/><category term="Java-Object"/><category term="Java-thread"/><category term="Java-設計模式"/><category term="Android-ADB"/><category term="C#"/><category term="C-基礎"/><category term="C-指標"/><category term="Dos-dos"/><category term="JNI"/><category term="Java-GUI"/><category term="Java-String"/><category term="Java-interface"/><category term="Java-其它類別"/><category term="Java-容器"/><category term="Java-正則表示式"/><category term="Java-異常"/><category term="Java-網路"/><title type='text'>學了又忘 忘了又學</title><subtitle type='html'>程式練習與紀錄</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>53</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-7347621493216690314</id><published>2013-08-15T11:00:00.000+08:00</published><updated>2017-06-23T15:45:09.978+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android-adroid"/><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><title type='text'>Android(java) 使用cmd</title><summary type="text">
在Android中，透過APK直接使用cmd指令與device溝通

private Process process = null;

String[] cmd1 = { &quot;/system/bin/sh&quot;, &quot;-c&quot;, &quot;echo hello &amp;gt; /data/temp.txt&quot;};
process = Runtime.getRuntime().exec(cmd1);

String[] cmd2 = { &quot;/system/bin/sh&quot;, &quot;-c&quot;, &quot;echo hello &amp;gt; /data/temp.txt&quot;};

process = Runtime.getRuntime().exec(cmd2);


</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/7347621493216690314/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2013/08/androidjava-cmd.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/7347621493216690314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/7347621493216690314'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2013/08/androidjava-cmd.html' title='Android(java) 使用cmd'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-8658859221258163840</id><published>2013-01-28T10:26:00.002+08:00</published><updated>2017-06-23T15:46:03.340+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android-adroid"/><title type='text'>Android suspend resume code</title><summary type="text">使用service定時發出broadcast，當接收者收到intent後，即啟動resume，隔15sec後release wakelock，讓系統自動進入sleep狀態

MainActivity.java
package com.example.alarmmain;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;

public class MainActivity extends Activity {
&amp;nbsp; &amp;nbsp; Receive receive = null;
&amp;nbsp; &amp;nbsp; @Override
&amp;nbsp; &amp;nbsp; </summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/8658859221258163840/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2013/01/android-suspend-resume-code.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/8658859221258163840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/8658859221258163840'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2013/01/android-suspend-resume-code.html' title='Android suspend resume code'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-3535952736826889033</id><published>2012-10-09T19:18:00.001+08:00</published><updated>2017-06-23T15:47:43.754+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android-adroid"/><title type='text'>Android 測試Android ProximityAlertReciever類別</title><summary type="text">測試Android ProximityAlertReciever類別
設定好監聽事件後，再更新座標，並接收警告或通知



Source code:

package com.example.addproximityalert;

import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/3535952736826889033/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/10/android-android-proximityalertreciever.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/3535952736826889033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/3535952736826889033'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/10/android-android-proximityalertreciever.html' title='Android 測試Android ProximityAlertReciever類別'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-1550143144600847809</id><published>2012-10-09T19:10:00.005+08:00</published><updated>2017-06-23T15:41:23.419+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-IO"/><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><title type='text'>Java 搜尋文字檔關鍵字並輸出</title><summary type="text">搜尋同一目錄內文字檔關鍵字後，並輸出整理到一個文字檔
可編譯為jar檔，重複使用

Source code:


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.regex.Matcher;


public class FindKeyWord {
    public static void main(String args[]) throws IOException{
        ReadClass mReadClass = new ReadClass()</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/1550143144600847809/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/10/java.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/1550143144600847809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/1550143144600847809'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/10/java.html' title='Java 搜尋文字檔關鍵字並輸出'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-7171934383257921516</id><published>2012-09-09T21:23:00.003+08:00</published><updated>2017-06-23T15:41:23.490+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux-linux"/><title type='text'>Make file</title><summary type="text">

Make file



基本說明

 

  
  
#include
  &amp;lt;stdio.h&amp;gt;

int
  main(void)

{

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;Hello World\n&quot;);

}

 


gcc hello.c&amp;nbsp; =&amp;gt;&amp;nbsp; 產生a.out&amp;nbsp;&amp;nbsp; 輸入./a.out即可執行

gcc –c
hello.c&amp;nbsp; =&amp;gt;&amp;nbsp; 產生
hello.o 目的檔

gcc –o hello
hello.o&amp;nbsp; =&amp;gt;&amp;nbsp; 產生 hello
可執行檔&amp;nbsp; 輸入./hello即可執行



-O:最佳化參數，-Wall:會產生詳細的編譯過程



gcc sin.c -lm -L/lib
-L/</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/7171934383257921516/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/09/make-file.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/7171934383257921516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/7171934383257921516'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/09/make-file.html' title='Make file'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-703313779351622944</id><published>2012-09-04T00:52:00.000+08:00</published><updated>2017-06-23T15:41:23.486+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><title type='text'>JAVA常遇到疑問</title><summary type="text">3-2.6 == 0.4 &amp;nbsp;=&amp;gt;為false

因為java使用基底型別進行浮點數計算時, 會不準確

3-2.6 為0.3999999999999



使用BigDecimal進行浮點數運算來解決



BigDecimal x = new BigDecimal(&quot;3&quot;);

BigDecimal x = new BigDecimal(&quot;2.6&quot;);

BigDecimal z = z.subtract(y);

double value = z.doubleValue();

System.out.println(value == 0.4);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/703313779351622944/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/09/java_4.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/703313779351622944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/703313779351622944'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/09/java_4.html' title='JAVA常遇到疑問'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-2102227755229983095</id><published>2012-09-04T00:35:00.000+08:00</published><updated>2017-06-23T15:41:23.423+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="JNI"/><title type='text'>JNI 記錄</title><summary type="text">
Java call C


Step 1: Write the Java Code
建立HelloWorld.java

 

  
  
//HelloWorld.java

public
  class HelloWorld

{

&amp;nbsp;&amp;nbsp;&amp;nbsp; public native void showHelloWorld();

&amp;nbsp;&amp;nbsp;&amp;nbsp; static {

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
  System.loadLibrary(&quot;hello&quot;);//呼叫libhello.so

&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/2102227755229983095/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/09/jni.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/2102227755229983095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/2102227755229983095'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/09/jni.html' title='JNI 記錄'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-60625102148999377</id><published>2012-09-02T15:01:00.001+08:00</published><updated>2017-06-23T15:41:23.467+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><title type='text'>Java版本 處理字幕檔</title><summary type="text">由於 java對中文的編碼有不同的格式, 處理字幕檔有些麻煩, 需先判斷編碼內容, 再去做處理, 輸出也不好處理, 最好找到一樣格式的srt檔案, 否則要先轉檔後再做擷取會比較好實作

程式內容:


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;


public class Subtitle {
    public static void main(String []args)throws IOException{
        GetSubtitle mGetSubtitle = new GetSubtitle();
        </summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/60625102148999377/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/09/java.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/60625102148999377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/60625102148999377'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/09/java.html' title='Java版本 處理字幕檔'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-3495258337441642421</id><published>2012-08-02T14:37:00.000+08:00</published><updated>2017-06-23T15:41:23.451+08:00</updated><title type='text'>Android整理</title><summary type="text">TextView
TextView &amp;nbsp;test = new TextView(context); &amp;nbsp;//或寫TextView(this) 以當前對象傳入
test.setText(&quot;訊息&quot;);
setContentView(test); //顯示在虛擬機上

改用 main.xml
&amp;lt;TextView &amp;nbsp;android:layout_width = &quot;fill_parent&quot;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;android:layout_width = &quot;warp_content&quot;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/3495258337441642421/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/08/android.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/3495258337441642421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/3495258337441642421'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/08/android.html' title='Android整理'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-614730288156905323</id><published>2012-07-09T16:53:00.000+08:00</published><updated>2017-06-23T15:41:23.470+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux-linux"/><title type='text'>Linux shell script</title><summary type="text">

設定變數值

 

  
LOCALTEST=”test”

輸出

echo $LOCALTEST



可用set查看目前的變量內容，退出後即清除變量內容



唯讀變量用readonly宣告，小心使用，因為不能修改與清除

readonly LOCALTEST

 






環境變量

$HOME/.bash_profile(/etc/profile)

使用export設置，而env可以查看環境變量內容

export 環境變量名稱=”環境變量內容”



 

  
${Variable name:+value}

  
如果設置了此變量，則顯示其值，否則為空

 

  
${Variable name:?value}

  
如果未設置了此變量，則顯示用戶定義錯誤訊息

 

  
${Variable name:-value}

  
如果未設置了此變量，則顯示其</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/614730288156905323/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/07/linux-shell-script.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/614730288156905323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/614730288156905323'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/07/linux-shell-script.html' title='Linux shell script'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-6454572373583416733</id><published>2012-06-06T11:22:00.001+08:00</published><updated>2017-06-23T15:41:23.476+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C-c"/><category scheme="http://www.blogger.com/atom/ns#" term="C-基礎"/><title type='text'>C 基本概念</title><summary type="text">



 

  


  
資料型態

  
型態說明

  
位元組

  
表示範圍

 

  
整數

  
long int

  
長整數

  
4

  
-2147483648~2147483647

 

  
int

  
整數

  
4

  
-2147483648~2147483647

 

  
short int

  
短整數

  
2

  
-32768~32767

 

  
char

  
字元

  
1

  
0~255

 

  
浮點數

  
float

  
浮點數

  
4 (6位精準)

  
1.2e-38~3.4e+38

 

  
double

  
倍精度浮點數

  
8 (15位精準)

  
2.2e-308~1.8e+308

 

  


  
long double

  


</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/6454572373583416733/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/06/c.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/6454572373583416733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/6454572373583416733'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/06/c.html' title='C 基本概念'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-8585929684135309990</id><published>2012-05-27T23:51:00.005+08:00</published><updated>2017-06-23T15:41:23.503+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C-c"/><category scheme="http://www.blogger.com/atom/ns#" term="C-指標"/><title type='text'>指標與結構</title><summary type="text">

指標整理

錯誤: int *ptr; *ptr = 35;

正確: int *ptr, number = 10; ptr = &amp;amp;number;



型式一:

int *ptr;

int num = 20;

ptr = &amp;amp;20;



型式二:

int num =20;

int *ptr = &amp;amp;num;







ptri&amp;nbsp;位址為&amp;nbsp;0012ff84，ptri +1&amp;nbsp;位址改為&amp;nbsp;&amp;nbsp;0012ff88

取得鄰近位址內的值&amp;nbsp;*(ptr+1)



++*ip，(*ip)++，需括號，因為單元運算子是由右向左做的



int* const p:&amp;nbsp;指向const的指標&amp;nbsp;可以改值,&amp;nbsp;不可以改位址

int const *p (相等於 const int* p); </summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/8585929684135309990/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/05/blog-post.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/8585929684135309990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/8585929684135309990'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/05/blog-post.html' title='指標與結構'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-4779801788524002791</id><published>2012-05-24T14:30:00.003+08:00</published><updated>2017-06-23T15:41:23.457+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java-正則表示式"/><title type='text'>JAVA 正則表示式</title><summary type="text">

正則表達式:&amp;nbsp;符合一定規則的表達式

用於專門操作字串，用一些特定的符號來表示一些代碼操作，簡化程式碼

//對號碼進行校驗

//長度5~15, 0不可第一位,&amp;nbsp;只可數字

 

  
class&amp;nbsp;Hello{

  

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;main(String[] args){

  

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String num =&amp;nbsp;&quot;123448940&quot;;

  

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int&amp;nbsp;len = num.length();

  

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/4779801788524002791/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/05/java_3924.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/4779801788524002791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/4779801788524002791'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/05/java_3924.html' title='JAVA 正則表示式'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-6954844168840657259</id><published>2012-05-24T14:29:00.002+08:00</published><updated>2017-06-23T15:41:23.480+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java-其它類別"/><title type='text'>JAVA 其它類別</title><summary type="text">

其他類:

System 類中的方法和屬性都是靜態類型，final類別不可實例化與繼承

in: 標準輸入，默認是鍵盤

out: 標準輸出，默認是螢幕



獲取系統屬性訊息: Properties getProperties();



class Main{

&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args){

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Proprties是Hashtable的子類，也就是Map集合的一個子類對象

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //可以通過map的方法取出該集合中的元素

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //該集合中存儲的</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/6954844168840657259/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/05/java_1459.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/6954844168840657259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/6954844168840657259'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/05/java_1459.html' title='JAVA 其它類別'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-3181515746694035144</id><published>2012-05-24T14:27:00.002+08:00</published><updated>2017-06-23T15:41:23.448+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java-異常"/><title type='text'>JAVA 異常</title><summary type="text">

異常: 程序在運行時出現不正常情況

分為兩種:

嚴重: java通過Error類別進行描述

非嚴重: java通過Exception處理



Throwable類別: 子類為Error、Exception

Exception在運行時運行出現的情況，可以通過try catch finally處理



編譯時異常: 必須throws，並讓調用者try and catch

非編譯時異常:
RuntimeException及其子類



方法:

getMessage()獲取異常資訊，返回字串

toString()獲取異常類名和異常資訊，返回字串

printStackTrace()獲取異常類名和異常資訊，以及異常出現在程式中的位元置。返回值void

printStackTrace(PrintStream s)通常用該方法將異常內容保存在日誌檔中，以便查閱



異常的處理</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/3181515746694035144/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/05/java_24.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/3181515746694035144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/3181515746694035144'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/05/java_24.html' title='JAVA 異常'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-2812262089642575510</id><published>2012-05-22T23:06:00.001+08:00</published><updated>2017-06-23T15:41:23.426+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java-集合"/><title type='text'>JAVA 集合(4) Map</title><summary type="text">

Map集合

該集合存儲鍵值對，而且要保證鍵的唯一性

l&amp;nbsp;&amp;nbsp;&amp;nbsp;增加

n&amp;nbsp;&amp;nbsp;&amp;nbsp;put(K key, V value)

n&amp;nbsp;&amp;nbsp;&amp;nbsp;putAll(Map&amp;lt;? extneds K, ?extends V&amp;gt; m)

l&amp;nbsp;&amp;nbsp;&amp;nbsp;刪除

n&amp;nbsp;&amp;nbsp;&amp;nbsp;clear()

n&amp;nbsp;&amp;nbsp;&amp;nbsp;remove(Object key)

l&amp;nbsp;&amp;nbsp;&amp;nbsp;判斷

n&amp;nbsp;&amp;nbsp;&amp;nbsp;containsKey(Object key)

n&amp;nbsp;&amp;nbsp;&amp;nbsp;containsVaule(Object value)

n&amp;nbsp;&amp;nbsp;&amp;nbsp;isEmpty()

l&amp;nbsp</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/2812262089642575510/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/05/java-3-map.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/2812262089642575510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/2812262089642575510'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/05/java-3-map.html' title='JAVA 集合(4) Map'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-7313488572723924675</id><published>2012-05-22T15:20:00.000+08:00</published><updated>2017-06-23T15:41:23.493+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android-ADB"/><category scheme="http://www.blogger.com/atom/ns#" term="Android-adroid"/><title type='text'>Android ADB</title><summary type="text">Slog.w(TAG, &quot;&quot;);

Slog 要用: adb
logcat -v time -b system

adb logcat &amp;gt; xxxx.log&amp;nbsp;



用eclipse進行android開發中經常遇到logcat無任何資訊輸出
解決辦法：window--&amp;gt;show view--&amp;gt;選擇android下的devices，打開devices，點擊右邊的截屏圖片。等到出現截圖的時候，logcat就出來資訊了



找到一個可以把log保存下來的方法，這樣如果不接USB線時操作手機發生問題就能看見log了

1. 連接USB&amp;nbsp;

2. 執行adb shell登到手機&amp;nbsp;

3. logcat -v time -f /sdcard/locker.log *:W
&amp;amp;&amp;nbsp;



ADB&amp;nbsp;系統除錯與連結工具指令

$</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/7313488572723924675/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/05/android-adb.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/7313488572723924675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/7313488572723924675'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/05/android-adb.html' title='Android ADB'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-6416949773004598614</id><published>2012-05-21T16:06:00.003+08:00</published><updated>2017-06-23T15:41:23.473+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java-集合"/><title type='text'>JAVA 集合(2)  Set</title><summary type="text">

HashSet

class&amp;nbsp;Hello{

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;main(String[] args){

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HashSet hs =&amp;nbsp;new&amp;nbsp;HashSet();

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hs.add(&quot;a&quot;);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hs.add(&quot;b&quot;);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hs.add(&quot;c&quot;);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/6416949773004598614/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/05/java-2-set.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/6416949773004598614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/6416949773004598614'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/05/java-2-set.html' title='JAVA 集合(2)  Set'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-5901662863755890316</id><published>2012-05-21T16:05:00.000+08:00</published><updated>2017-06-23T15:41:23.463+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java-集合"/><title type='text'>JAVA 集合(3) 泛型</title><summary type="text">

泛型

發生異常現象，使用泛型解決，JDK1.5出現的，用於解決安全問題

public&amp;nbsp;class&amp;nbsp;Main{

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;main(String[] args){

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArrayList al =&amp;nbsp;new&amp;nbsp;ArrayList();

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; al.add(&quot;ajij&quot;);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; al.add(&quot;ceccsd&quot;);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/5901662863755890316/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/05/java_7561.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/5901662863755890316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/5901662863755890316'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/05/java_7561.html' title='JAVA 集合(3) 泛型'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4453668544708709700.post-3044230296232373016</id><published>2012-05-21T15:09:00.000+08:00</published><updated>2017-06-23T15:41:23.444+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java-JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Java-集合"/><title type='text'>JAVA 集合(1) List</title><summary type="text">集合類

物件導向對事物都是以物件的形式，所以為了方便對多個物件的操作，就對物件進行存儲，集合就是存儲物件最常用的一 種方式



陣列和集合類同是容器，有何不同？

陣列雖然也可以存儲物件，但長度是固定的

集合長度是可變的。 陣列中可以存儲基底資料型別，集合只能存儲物件，集合可以存儲不同類型的物件。






















集合框架中的常用介面

Collection介面有兩個子介面：

List（列表），Set（集）

List：可存放重複元素，元素存取是有序

Set：不可以存放重複元素，元素存取是無序



基本方法使用:

class Hello{

&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[]
args){

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /</summary><link rel='replies' type='application/atom+xml' href='http://kent2480.blogspot.com/feeds/3044230296232373016/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://kent2480.blogspot.com/2012/05/java_21.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/3044230296232373016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4453668544708709700/posts/default/3044230296232373016'/><link rel='alternate' type='text/html' href='http://kent2480.blogspot.com/2012/05/java_21.html' title='JAVA 集合(1) List'/><author><name>kent</name><uri>http://www.blogger.com/profile/13572428241518722088</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTOp7uiK-VL8NXeOM8Ft7uw7WbJ9ghMWn7L9dT8MTE5nBXnjOmh9pcwwJBfOIN3nZMZ1jXyYZcH7cCCwGBRTvp1-RYGeVMlJXjHhLwgYcgm5Hb0-918MQYpi5zcl5VfQ/s220/%E7%85%A7%E7%89%87071.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBBOPkQuuN4c6D1CQ0EUwXbhcl41lbWNTTV7QUMtTpeRHOwYy_lLTVa50iEjVB_QXKIqdJqQcUJ9wFi5u-VMm8b3JW1urzkwYkWSlCFK9-4Jr1Cl35qqd5-BYIYxnXYSJr2lsSnE11wFUt/s72-c/1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>