原创 App開機自啓動

App開機自啓動 通過開機廣播來實現自啓動 定義開機廣播 public class BootCompletedReceiver extends BroadcastReceiver { @Override public v

原创 選擇排序 (java)

介紹 選擇待排序序列中選擇最小的元素,然後和待排序序列的第一個元素交換位置 將剩下的待排序序列中選擇最小的元素,和待排序序列的第二個元素交換位置 重複以上步驟,直到將整個序列都排序。 因爲在不斷的選擇剩餘最小的元素,所以稱之爲

原创 Kotlin中變量、常量以及空安全

Kotlin的可空類型 在以往的Java開發中有一個著名的異常NullPointerException,俗稱NPE,它由訪問爲空的屬性引發,爲此Kotlin中引入了可空類型,旨在有效消除NPE異常的發生。 在定義變量的時候在其類型

原创 Handler機制-Looper源碼解析

Handler機制-Looper源碼解析 一、介紹 安卓中Handler框架處理消息,其中Looper類用來循環從MessageQueue類中獲取消息,然後調用Handler進行消費.本文將基於安卓9.0代碼帶分析Looper的實

原创 Mac端dart環境搭建和第一個Dart程序

安裝Dart Sdk Dart Sdk用來開發web和服務器端,如果開發移動app直接使用flutter就可以了. 下面是mac下搭建Dart教程 安裝 Dart Sdk brew tap dart-lang/dart bre

原创 top命令查看進程信息和cpu佔用

top 通過top命令查看進程信息 通過adb shell top -h查看其使用方法 yumodeMacBook-Pro:car yumo$ adb shell top -h Usage: top [ -m max_procs

原创 抽象工廠模式-java實現

抽象工廠模式 Provide an interface for creating families of related or dependent objects without specifying their concrete c

原创 單例模式-Java 實現

單例模式的定義 確定某類只有一個實例,而且自行實例化並向整個系統提供這個實例。 單例模式類圖 一個單例模式的例子 public class Singleton { //自行生成一個類的實例。 private stat

原创 工廠模式-java實現

工廠方法模式的介紹 工廠模式屬於創建性模式,應用的非常廣泛,提供了一種非常好的創建對象方式。 工廠方法的定義: Define an interface for creating an object , but let subclass

原创 Leetcode-14 Longest Common Prefix

14. Longest Common Prefix 原題目 Write a function to find the longest common prefix string amongst an array of strings.

原创 Leetcode-26 Remove Duplicates from Sorted Array (java)

layout: post title: 26-Remove Duplicates from Sorted Array category: leetcode tags: java, leetcode, airthmetic keywo

原创 Leetcode-21 Merge Two Sorted Lists (java)

21. Merge Two Sorted Lists 原題目 Merge two sorted linked lists and return it as a new list. The new list should be made

原创 Leetcode-19 Remove Nth Node From End of List

19. Remove Nth Node From End of List 原題目 Given a linked list, remove the nth node from the end of list and return its

原创 Kotlin中的變量、常量、const

變量和常量 在Kotlin中使用val和var關鍵字來聲明變量,其語法如下: val|var 變量名[: 變量類型][= 值] val關鍵字聲明一個常量,賦值以後不再修改。 var關鍵字聲明一個變量,可以重複賦值。 下面聲明一個字符串

原创 Leetcode-20 Valid Parentheses

20. Valid Parentheses 原題目 Given a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if