在阅读了c#的隐藏特性之后,我想知道Java的隐藏特性有哪些?
当前回答
javabean属性访问器方法不必以“get”和“set”开头。
甚至Josh Bloch在《Effective Java》中也犯了这个错误。
其他回答
你可以在局部类的初始化块和方法中访问最终的局部变量和参数。考虑一下:
final String foo = "42";
new Thread() {
public void run() {
dowhatever(foo);
}
}.start();
有点像个了结,不是吗?
显然,在一些调试版本中,有一个从HotSpot: http://weblogs.java.net/blog/kohsuke/archive/2008/03/deep_dive_into.html转储本机(JIT)程序集代码的选项
不幸的是,我无法通过那篇文章中的链接找到构建,如果有人能找到一个更精确的URL,我很乐意使用它。
作为初学者,我非常欣赏Java 6中的JConsole监控软件,它已经为我解决了一些问题,而且我还在不断地寻找它的新用途。
显然JConsole在Java 5中已经有了,但我认为现在它已经改进了,至少现在工作得更稳定了。
Java 5中的JConsole: Java 5中的JConsole
Java 6中的JConsole: Java 6中的JConsole
当你在做它的时候,好好看看本系列中的其他工具: java6故障排除工具
静态导入可以“增强”语言,这样你就可以以类型安全的方式做一些漂亮的文字工作:
List<String> ls = List("a", "b", "c");
(也可以做映射,数组,集)。
http://gleichmann.wordpress.com/2008/01/13/building-your-own-literals-in-java-lists-and-arrays/
更进一步说:
List<Map<String, String>> data = List(Map( o("name", "michael"), o("sex", "male")));
The power you can have over the garbage collector and how it manages object collection is very powerful, especially for long-running and time-sensitive applications. It starts with weak, soft, and phantom references in the java.lang.ref package. Take a look at those, especially for building caches (there is a java.util.WeakHashMap already). Now dig a little deeper into the ReferenceQueue and you'll start having even more control. Finally grab the docs on the garbage collector itself and you'll be able to control how often it runs, sizes of different collection areas, and the types of algorithms used (for Java 5 see http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html).
推荐文章
- 在流中使用Java 8 foreach循环移动到下一项
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 用Java计算两个日期之间的天数
- 如何配置slf4j-simple
- 在Jar文件中运行类
- 带参数的可运行?
- 我如何得到一个字符串的前n个字符而不检查大小或出界?
- 我可以在Java中设置enum起始值吗?
- Java中的回调函数
- c#和Java中的泛型有什么不同?和模板在c++ ?
- 在Java中,流相对于循环的优势是什么?
- Jersey在未找到InjectionManagerFactory时停止工作
- 在Java流是peek真的只是调试?
- Recyclerview不调用onCreateViewHolder
- 将JSON字符串转换为HashMap