#10 effective java: item 6
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.example.effectivejava.chapter01.item06;
|
||||
|
||||
public class Client {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Deprecation deprecation = new Deprecation();
|
||||
Deprecation deprecation1 = new Deprecation("string");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.example.effectivejava.chapter01.item06;
|
||||
|
||||
public class Deprecation {
|
||||
|
||||
/**
|
||||
* @deprecated in favor of
|
||||
* {@link #Deprecation(String)}
|
||||
*/
|
||||
@Deprecated(forRemoval = false, since = "1.2")
|
||||
public Deprecation() {
|
||||
}
|
||||
|
||||
private String name;
|
||||
|
||||
public Deprecation(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.example.effectivejava.chapter01.item06;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class RegularExpression {
|
||||
|
||||
private static final Pattern SPLIT_PATTERN = Pattern.compile(",");
|
||||
|
||||
public static void main(String[] args) {
|
||||
long start = System.nanoTime();
|
||||
for (int j = 0; j < 10000; j++) {
|
||||
String name = "keesun,whiteship";
|
||||
name.split(",");
|
||||
// SPLIT_PATTERN.split(name);
|
||||
}
|
||||
System.out.println(System.nanoTime() - start);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user