#10 effective java: item 6

This commit is contained in:
haerong22
2022-05-24 07:50:57 +09:00
parent 75848752a2
commit 8188d0fc15
3 changed files with 45 additions and 0 deletions

View File

@@ -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");
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}