現在位置: 首頁 > 編程語言 > 文章
2018年09月13日 編程語言 ⁄ 共 529字 評論關閉
1.從main函數開始 int main() { return 0; } 操作系統通過調用main函數來執行程序,main函數執行組成自己的語句並返回一個值操作系統。返回0值表明程序成功執行完畢。(非0的返回值都有操作系統定義的含義) 2.輸入和輸出 輸入和輸出功能(IO)是由標準庫提供的,iostream庫的基礎是兩種命名為istream和ostream的類型。 標準輸入(istream)  cin 標準輸出(ostream)  cout      cerr(標準錯誤)    clog(一般信息) #incl...
閱讀全文
2018年09月11日 編程語言 ⁄ 共 417字 評論關閉
本文主要介紹UCDetector(無用代碼掃描工具)使用方法及局限   對於沉積或多方接手開發的項目經常會遇到一坨一坨無用的代碼,但一個一個類查找又相當費時,這裡介紹一個eclipse插件掃描沒有引用的類、方法、常量。   插件名為UCDetector,介紹地址為http://www.ucdetector.org/index.html eclipse update site為:http://ucdetector.sourceforge.net/update   使用方法為在工程上(可以shift選擇多個模塊)右擊選擇UCDet...
閱讀全文
如今用spring ioc容器進行介面注入,會給程序帶來極大的靈活性,編程過程中要想查看一個對象的方法時一般要按注Ctrl鍵再單擊左鍵就會跳轉過去,可是面向介面編程時這樣做會跳到介面里,有沒有好方法可以直接跳到介面的實現代碼中,有!implementors可以做到強烈推薦大家安裝! 插件名稱: implementors 更新地址: http://eclipse-tools.sourceforge.net/updates 安裝步驟: 進入 Help -> Soft Ware Updates -> Find and...
閱讀全文
2018年09月11日 編程語言 ⁄ 共 566字 評論關閉
public static String loadFileAsString(String filePath) throws java.io.IOException{ StringBuffer fileData = new StringBuffer(1000); BufferedReader reader = new BufferedReader(new FileReader(filePath)); char[] buf = new char[1024]; int numRead=0; while((numRead=reader.read(buf)) != -1){ String readData = String.valueOf(buf, 0, numRead); fileData.append(...
閱讀全文
2018年09月11日 編程語言 ⁄ 共 1434字 評論關閉
在android的開發中,尤其是與訪問網路有關的開發,都要判斷一下手機是否連接上了網路,下面是一個判斷是否連接網路的編碼 package cn.com.karl.util; import com.kubu.main.R; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.net.ConnectivityManager; import android.net.Network...
閱讀全文
2018年09月11日 編程語言 ⁄ 共 346字 評論關閉
你要訪問其他的程序,那麼這個程序要先裝在到模擬器或真機上面,因為我們要使用要訪問其他程序的包。 簡單的訪問有以下兩種方式(目前只知道這兩種): 一、使用Intent的setComponent方法 Intent intent = new Intent(); intent.setComponent(new ComponentName("包名", "包名.主類名")); intent.setAction(Intent.ACTION_VIEW); startActivity(intent); 二、使用包管理器 Intent intent = new Intent(); intent = getP...
閱讀全文
在自己的項目中集成另一個apk,設置這個apk不在桌面上顯示,並在自己的項目中能夠啟動這個apk~首先用apk tool反編譯需要集成的apk,刪除AndroidManifest.xml中的luncher啟動標誌,然後在使用apk tool進行打包,生成新的apk // 方法一 Intent intent = new Intent(); // packageName為應用包名,activityFullName為具有luncher標識的activity的全路徑名稱 ComponentName comp = new ComponentName(packageName, activityFul...
閱讀全文
2018年09月10日 編程語言 ⁄ 共 1565字 評論關閉
啥也不說了,直接來碼 public class TimerTestActivity extends Activity { private TextView txt; private Handler handler = new Handler(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); txt = (TextView) findViewById(R.id.txt); txt.setText("0.00"); // txt.setTex...
閱讀全文
2018年09月09日 編程語言 ⁄ 共 4292字 評論關閉
閉包 2.0.0p247 :133 > def my_method 2.0.0p247 :134?> x="GoodBye" 2.0.0p247 :135?> yield("cruel") 2.0.0p247 :136?> end => nil 2.0.0p247 :137 > x = "Hello" => "Hello" 2.0.0p247 :138 > my_method {|y| "#{x}, #{y} world"} => "Hello, cruel world" 2.0.0p247 :139 > 作用域 塊作用域   作用域門 2.0.0p247 :139 > v1 =1 => 1 2.0.0p247 :140 > ...
閱讀全文
2018年09月09日 編程語言 ⁄ 共 795字 評論關閉
1.Kernel#eval 2.0.0p247 :428 > array = ['10','20'] => ["10", "20"] 2.0.0p247 :429 > element = '30' => "30" 2.0.0p247 :430 > eval('array << element') => ["10", "20", "30"] 2.0.0p247 :431 > 對比方法與塊 .0.0p247 :422 > array = ['a','b','c 2.0.0p247 :423'> '] => ["a", "b", "c\n"] 2.0.0p247 :424 > x = 'abc' => "abc" 2.0.0p247 :425 >...
閱讀全文