建议42: 让工具类不可实例化 Java项目中使用的工具类非常多,比如JDK自己的工具类java.lang.Math.java.util.Collections等都是我们经常用到的.工具类的方法和属性都是静态的,不需要生成实例即可访问,而且JDK也做了很好的处理,由于不希望被初始化,于是就设置构造函数为private访问权限,表示除了类本身外,谁都不能产生一个实例,我们来看一下java.lang.Math代码: public final class Math { /** * Don't let
看rocketmq源码的时候发现他们还给时钟封装里一下. /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The A
string pcname = Dns.GetHostName(); string ip = Dns.GetHostAddresses(pcname).First().ToString(); using Com.AppCode.Extend; using Com.AppCode.Helper; using System.Collections.Generic; using System.Net; using System.Net.NetworkInformation; using System.