随便整理的一些自用的Java Related
Install
JDK8
Using previous jdk8
IntelliJ Idea
Statement
https://blog.csdn.net/qq_27093465/article/details/52918873
https://github.com/judasn/IntelliJ-IDEA-Tutorial
MAVEN
Java Cookbook
// Split String
for (String word: "test test".split(" ")){
System.out.println(word);
// Stringbuffer
StringBuffer sb = new StringBuffer();
sb.append("gavinfly");
System.out.println("original stringbuffer==>"+sb);
sb.append("fei");
System.out.println("after append fei==>"+sb);
sb.insert(5,"!!");
System.out.println("insert from position 5=>"+sb);
sb.delete(7,10);
System.out.println("delete [7,10)==>"+sb);
sb.reverse();
System.out.println("reverse the string==>"+sb);
sb.replace(0,3,"123");
System.out.println("replace [0,3)==>"+sb);
StringBuilder sb1 = new StringBuilder();
for (String word : "test test".split(" ")) {
if (sb1.length() > 0) {
sb1.append(", ");
}
sb1.append(word);
}
System.out.println(sb1);
// 构造函数 => 给类对象赋初始
public class Person{
String name;
int age;
Person(String name, int age){
this.name=name;
this.age=age;
}
public static void main(String[] args){
Person p = new Person("gavin",28);
System.out.println("name :"+p.name+" age: "+p.age);
}
}
//ArrayList
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList<String> testArrayList = new ArrayList<String>();
testArrayList.add("Google");
testArrayList.add("hello");
testArrayList.set(1,"Wiki");
testArrayList.remove(0);
System.out.println(testArrayList);
System.out.println(testArrayList.size());
}
}