今天在做一个将String转换为Integer的功能时,发现Integer.parseInte()会抛出异常NumberFormatException. 函数Integer.parseInt(String)定义 public static int parseInt(String s) throws NumberFormatException 测试代码: public class Test { public static void main(String[] args) { Integer num
1 线程不安全的实现方法 首先介绍java中最基本的单例模式实现方式,我们可以在一些初级的java书中看到.这种实现方法不是线程安全的,所以在项目实践中如果涉及到线程安全就不会使用这种方式.但是如果不需要保证线程安全,则这种方式还是不错的,因为所需要的开销比较小.下面是具体的实现代码: public Class Singleton { private static Singleton instance = null; private Singleton(){} public static Sin
JAVA中的四种JSON解析方式详解 我们在日常开发中少不了和JSON数据打交道,那么我们来看看JAVA中常用的JSON解析方式. 1.JSON官方 脱离框架使用 2.GSON 3.FastJSON 有问题 4.jackson 常用 JSON操作涉及到的类: public class Student { private int id; private String name; private int age; public int getId() { return id; } public vo