Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions


and many more ....



In today’s post-OO world, is dependency injection still relevant?

It’s 2015. Most of the new popular languages are more or less functional. The old ones, like Java, gain functional programming elements. In Scala, people are increasingly leaning towards the pure side, using more FP and less OO. So – Dependency Injection? Really? You could say that DI is just using (constructor) parameters. I’m saying that as well in my ...

Read More »

Joining Strings in JDK 8

JDK 8 introduced language features such as lambda expressions, streams, and even the new Date/Time API that will change the way we write Java applications. However, there are also several new APIs and features that might be less “game changing,” but still bring greater convenience and expressiveness to the Java programming language. In this post, I look at one of ...

Read More »

Do Primitives Need To Go?

I am currently working on an enterprise application using JSF as the view technology and JPA for the persistence layer. It may have been something in a backing bean or service method, but it struck me: Is there a good reason to use primitives anymore in enterprise applications? When I started programming with Java around J2SE 1.2 (or was it ...

Read More »

Very fast Camels and Cloud Messaging

Apache Camel is a popular, mature, open-source integration library. It implements the Enterprise Integration Patterns which is a set of patterns that often come up when integrating distributed systems. I’ve written a lot about Camel in the past, including why I like it better than Spring Integration, how the routing engine works, how to use JMS selectors with AWS SQS, ...

Read More »

Hibernate Locking Patterns – How does PESSIMISTIC_READ and PESSIMISTIC_WRITE work

Introduction Java Persistence API comes with a thorough concurrency control mechanism, supporting both implicit and explicit locking. The implicit locking mechanism is straightforward and it relies on: Optimistic locking: Entity state changes can trigger a version incrementation Row-level locking: Based on the current running transaction isolation level, the INSERT/UPDATE/DELETE statements may acquire exclusive row locks While implicit locking is suitable ...

Read More »

Fetching List of message codes from

Normally messages from message properties are fetched via, key i.e. message code, What if we want to select more than one message property, like a list. To get a list of select message codes from, we need to customize messageSource bean. To do that, lets create a class ‘CustomisedPluginAwareResourceBundleMessageSource’ which should extend class ‘PluginAwareResourceBundleMessageSource’. To fetch all properties we ...

Read More »

Thoughts about TDD and how to use it for untested legacy code

Prologue My personal experiences with TDD mostly match with the others on the internet, in short, TDD is good. It helps you to write better code, create a clean and nicely tested architecture, make refactoring and design changes easier. It leads your design decisions, helps to think through every possible cases which you need to handle and many more. I ...

Read More »

115 Java面试问题和答案 –终极列表(PDF 下载)

在本教程中我们会讨论在Java面试中可能被用到的各种类型的问题,以便面试官来测试你的Java和面向对象开发(OOP)方面的大概水平。 在接下来的章节我们会讨论面向对象编程(OOP)和它的特点,关于Java及其功能的常见问题,Java 集合框架(Collections), 垃圾回收,异常处理,Java applets, Swing, JDBC, 远程方法调用(RMI), Servlet 和JSP。 让我们开始吧! 目录 面试对象编程(OOP) Java的一些常见问题 Java线程 Java集合 垃圾回收 异常处理 Java Applets Swing JDBC 远程方法调用(RMI) Servlets JSP 面试对象编程(OOP) Java是并发的,基于类和面向对象的编程语言。面向对象的软件开发具有以下优点: 模块化的代码开发,使维护和修改更加容易。 代码的复用性。 提高代码的可靠性和灵活性。 代码更易理解。 面向对象的编程具有一些重要的特征, 例如封装,继承,多多和抽象。我们会在以下章节逐个分析这些特征。 封装 封装为对象赋予了隐藏其内部特征和行为的能力。每一个对象都有一些方法,这些方法能被其他对象访问并改变对象内部数据。在Java中,有三种访问修饰符:public,private和protected。每一种修饰符赋予其他类一些访问权限,这些类可以是在同一个包里或者不同包。下面列出了使用封装的好处: 每一个对象的内部状态都通过隐藏其属性来保护。 提高了代码的复用性和可维护性,因为对象的行为可以被独立的改变或扩展。 通过阻止对象间的非预期的相互访问,提高了模块化水平。 你可以参考一下文档here来获得更多的关于封装的细节和例子。 多态 多态是编程语言用来为底层数据类型提供不同接口的能力。一个多态类型的操作也可以被应用到一些其他类型的值。 继承 继承为对象赋予了访问其他类的成员字段和方法的能力,这个其他类也被称作基类。继承提供了代码的可重用性,而且可以被用来为已存在的类增加新的功能,而不用改变基类。 抽象 抽象是分离概念(idea)和特定实例(specific instances)的过程,所以可以开发一些具有特定功能的类,而不是一些具体实现细节。Java支持抽象类,它们并不是所有方法都有具体实现。抽象技术的目的是分离类的行为和实现细节。 抽象和封装的区别 抽象和封装是互补的概念。一方面,抽象关注于一个对象的行为。另一方面,封装关注对象行为的实现细节。封装通常是通过隐藏对象内部状态来达到的,所以,可以视作一种提供抽象的策略。 Java的一些常见问题 1. 什么是Java虚拟机?为什么java被称作平台独立的编程语言?  Java虚拟机是一个能处理Java字节码的进程。每一个Java源文件都会被编译成字节码文件,然后被Java虚拟机执行。从设计上看,Java允许程序在任何一个平台上执行,而不用程序员在每一个不同平台上进行重写或重编译。Java虚拟机能做到这一点,是因为它了解底层硬件平台的指令长度和其他细节。 2. JDK和JRE有什么区别?  JRE基本上就是java虚拟机,也就是Java程序执行的地方。它也包含浏览器的applet插件。JDK是java的全功能开发软件包(SDK),包括了JRE,编译器和工具(比如JavaDoc, Java Debugger)。这些功能是为用户用作开发、编译和执行java程序的。 3. 关键字”static”是什么意思? 在Java中能够重写(override)私有或者静态方法吗? static关键字表示一个变量或方法在不用实例化它所属于的类的情况下就可以访问。在java中用户不能重写(override)静态方法,因为方法重写是基于运行时的动态绑定,而静态方法是在编译时绑定的。一个静态方法不能与这个类的任何实例关联,所以这种说法是不对的。 4. 能够在静态上下文中访问非静态的变量吗? Java中的静态变量属于类,它的值对这个类的所有实例都是一样的。静态变量在类被java虚拟机加载时就就被初始化。如果代码尝试访问没有实例的非静态变量,编译器会报错,因为这些变量还没有被创建,而且它们没有与任何实例关联。 ...

Read More »