- J2SE(桌面程序开发),c/s(安装客户端)
- J2EE(企业级开发),b/s(用浏览器访问)
- J2ME(手机端开发)
注意:Java核心API(Application Programming Interface:应用程序编程接口),上述3种类型的开发都会用到的类。
- JDK(java development kit:java 开发 成套工具):包含JRE, Java编译器(javac.exe),Java程序调试和分析的工具,Java基础的类库
- JRE(java runtime environment:java 运行 环境):包含Java虚拟机(JVM)标准实现,java核心类库
- JVM(java Virtual Machine:java虚拟机):包含解释器(java.exe)和即时编译器(JIT:just in time)
注解:如果你需要编写java程序,需要安装JDK。如果你需要运行java程序,只需要安装JRE就可以了。
- 编译时环境(预编译):.java文件-》java编译器(javac.exe)-》.class文件(.class字节码:介于java源文件和机器码之间)
- 运行时环境:.class文件-》JVM中的解释器(或即时编译器编译热点代码)-》运行程序
- 热点代码:Java程序最初是通过解释器(Interpreter)进行解释执行的,当虚拟机发现某个方法或代码块的运行特别频繁时,就会把这些代码认定为“热点代码”。
- 即时编译器:为了提高热点代码的执行效率,在运行时,虚拟机将会把这些代码编译成与本地平台相关的机器码,并进行各种层次的优化,完成这个任务的编译器称为即时编译器(Just In Time Compiler)。
- java.lang.*下的所有类都不许需要手动导包
- object类是所有类的父类,object中的所有公共方法,其他类都能调用
- public boolean equals(Object obj):比较的是对象的引用,String类重写了该方法(比较的是字符串的内容)
- public String toString():一般要重写
- 栈内存:存放基本数据类型变量、引用变量
- 堆内存:存放对象
- public char charAt(int index)
- public int length()
- public int indexOf(String str)
- public String substring(int beginIndex, int endIndex)
- public String replace(CharSequence target, CharSequence replacement)
- public String replaceFirst(String regex, String replacement)
- public String toUpperCase()
- public String toLowerCase()
- public boolean equals(String anotherString):比较两个字符串的内存是否相等,==是比较的两个字符串的地址是否相等
- pulic boolean equalsIgnoreCase(String antherString)
- public boolean contentEquals(String antherString)
- public String[] split(String regex)
- 对于值类型,比较的是数值
- 对于引用类型,比较的是地址
- 基本数据类型对象的包装类:Byte Short Integer Long Float Double Charactor Boolean
- Integer.MAX_VALUE
- 将字符串转变为整数:Integer.parseInt(“123”);
- 包装类中equals方法重写了,比较的是值
- 注意.toString()方法
- public static int abs(int a)
- public static double random()
- public static int max(int a, int b)
- public static final double PI
- public static double pow(double a, double b)
- public static double floor(double a)
- public static double ceil(double a)
- public static void sort(int[] a)
- public static String toString(int[] a)
- 单例集合:Collection(接口)
List(接口):有顺序,允许重复。(ArrayList,LinkedList)
Set(接口):无顺序,不能有重复数据。(HashSet,TreeSet)
常用方法:
public boolean add(E e)
public boolean addAll(Collection extends E> c)
public void clear()
public boolean contains(Object o)
public boolean equals(Object o)
public boolean isEmpty()
public Iterator iterator()
public boolean remove(Object o)
public int size()
public Object[] toArray() - 双列集合:Map(接口):HashMap
常用方法:
public V get(Object key)
public Set keySet()
public V put(K key, V value)
public V remove(Object key)
public int size() - java.util.ArrayList:
get(int index) - java.util.LinkedList:
addFirst(int index)
addLast(int index)
set(int index, Object obj) - 迭代器:
Iteratoriterator = arrayList.iterator(); while(iterator.hasNext()) { Person person = iterator.next(); System.out.println(person); }
-
java.util.TreeSet
存入的时候有顺序
first()
last()
floor() lower()
ceiling() higher()
pollFirst()
pollLast()
subSet(E first, E last)
tailSet(E e) -
java.util.HashMap
public boolean containsKey(K key)
public boolean containsValue(V value)
遍历://方法1 //java.util.Map.Entry //java.util.Iterator Set
> set = map.entrySet(); for(Entry en : set) { System.out.println(en.getKey()); System.out.println(en.getValue()); } //方法2 Iterator iterator = set.iterator(); whie(iterator.hasNext()) { Entry entry = iterator.next(); System.out.println(entry); } -
java.util.Collections
sort()
reverse()
shuffle()



