Android的界面一般都是Java开发的,因此对于c++,.net人员来说理解和编写有一个适应过程,最近参考了一下资料,把这些涉的一些java基础使用以例子代码的形式总结起来,记录了这个平台的熟悉过程。
文件目录(涉及了java的一些主要语法)
AnnotDefine.java
AnnotDemo.java ClassDemo.java
CodeResource_en_US.java Collection.java
demo.java example_en_US.properties
Generic.java InitDemo.java
IO.java LocalResource.java
Nest.java PrefsDemo.java
ThreadDemo.java
以下是一些简要的说明(JDK),具体的使用和一些说明参考以上的例子
Collections Framework
包:java.util
接口
核心和层次关系
Iterable, Collection, List, Set, SortedSet, Queue, Map, and SortedMap.
实现类
实现类约定:
Abstract开头的是抽象类,用于减少多个实现的代码重复
具体的类以接口的名字结尾,如ArrayList实现的事List接口
如下是JDK中的实现类列表
AbstractCollection, AbstractList, AbstractQueue, AbstractSequentialList, AbstractSet,
ArrayBlockingQueue, ArrayDeque, ArrayList, AttributeList, ConcurrentLinkedQueue, ConcurrentSkipListSet, CopyOnWriteArrayList, CopyOnWriteArraySet, DelayQueue, EnumSet, HashSet, JobStateReasons, LinkedBlockingDeque, LinkedBlockingQueue, LinkedHashSet, LinkedList, PriorityBlockingQueue, PriorityQueue, RoleList, RoleUnresolvedList, Stack, SynchronousQueue, TreeSet, Vector
工具类
数组和容器的遍历方法
Collection<String> col = …
Iterator iter = col.iterator();
while (iter.hasNext())
System.out.println(iter.next());
for (String s: col)
System.out.println(s);
嵌套类型Nested Type
There are four kinds of nested classes: static member classes, nonstatic member classes, anonymous classes, and local classes. The latter three categories are known as inner classes.
注释类型annotations
java.lang
Deprecated
Override
SuppressWarnings
java.lang.annotation
Documented
Inherited
Retention
Target
javax.annotation
Generated
PostConstruct
PreDestroy
Resource
Resources