diff --git a/java/CatchDemo.java b/java/CatchDemo.java new file mode 100644 index 0000000000000000000000000000000000000000..7414205b7cc418dc61c90a3cc77f8b5c7790a605 --- /dev/null +++ b/java/CatchDemo.java @@ -0,0 +1,11 @@ +class CatchDemo { + + // 异常捕获,什么事都不做 + static { + try { + gun = Resources.parseModel("images/gun.txt"); + } catch (FileNotFoundException e) { + } catch (IOException e) { + } + } +} \ No newline at end of file diff --git a/java/SinletonDemo.java b/java/SinletonDemo.java new file mode 100644 index 0000000000000000000000000000000000000000..4269d44c23d1dd50ee921bc5378b9be8cdffa6d4 --- /dev/null +++ b/java/SinletonDemo.java @@ -0,0 +1,14 @@ +class SingletonDemo { + + // 单例写法参加:https://blog.51cto.com/aiilive/2164281 + public static class Singleton { + // 坑人的单例 + static Singleton i = null; + + public static Singleton Instance() { + if (i == null) + i = new Singleton(); + return i; + } + } +} \ No newline at end of file