Java 面试题(1)
创建不可修改的对象
不提供setter方法
实例变量声明private final
final class 修饰类,防止继承
方法返回时,final修饰的实例变量可以直接返回,否则返回copy。
不可变对象的优点
方便创建、使用和测试。
线程安全的(String)
适合作为Map和Set的Key。
允许hashcode延迟初始化和缓存
example
123...
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick StartCreate a new post1$ hexo new "My New Post"
More info: Writing
Run server1$ hexo server
More info: Server
Generate static files1$ hexo generat...
MongoDB in practice
#MongoDB in Priactice
1. install安装路径 G:\Tools\MongoDB
2. onfig新建mongodb.config放到G:\Tools\MongoDB\bin内容
12345## 数据库文件目录 dbpath=G:/Tools/MongoDB/data ## 日志目录 logpath=G:/Tools/MongoDB/log/mongo.log d...
MyBatis 入门
MyBatis 入门
安装12345<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>x.x.x</version></dependency>
从XML中构建SqlSes...
Java Bit 操作优化算法
Java Bit 操作优化算法
基本操作符
& 或
| 与
^ 异或
! 非
<< 左移
>> 右移
>>> 无符号右移
Examples
统计1的bit个数1234567int count_one(int n) { while(n) { n = n&(n-1); count++; } return count;}
判断是否4的N次方1234bool isPowerOfFour(int n) { return !(n&(n-1)) && (n&0x55555555); //check t...