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 ....

 

 

Fetching List of message codes from message.properties

grails-logo

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 message.properties, 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

software-development-2-logo

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-logo

在本教程中我们会讨论在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 »

RESTful Charts with JAX-RS and PrimeFaces

jsf-logo

Oftentimes, it is useful to utilize a chart for providing a visual representation of your data. PrimeFaces supplies charting solutions that make it easy to add visual representations of your data into web and mobile applications. If we couple the use of PrimeFaces charting components with RESTful web service data, we can create custom charts that scale well for both ...

Read More »

Async abstractions using rx-java

java-logo

One of the big benefits in using Rx-java for me has been the way the code looks exactly the same whether the underlying calls are synchronous or asynchronous and hence the title of this entry. Consider a very simple use case of a client code making three slow running calls and combines the results into a list:       ...

Read More »

Dropwizard, MongoDB and Gradle Experimenting

gradle-logo

Introduction I created a small project using Dropwizard, MongoDB and Gradle. It actually started as an experimenting Guava cache as buffer for sending counters to MongoDB (or any other DB). I wanted to try Gradle with MongoDB plugin as well. Next, I wanted to create some kind of interface to check this framework and I decided to try out DropWizard. ...

Read More »

Resolve coreference using Stanford CoreNLP

software-development-2-logo

Coreference resolution is the task of finding all expressions that refer to the same entity in a text. Stanford CoreNLP coreference resolution system is the state-of-the-art system to resolve coreference in the text. To use the system, we usually create a pipeline, which requires tokenization, sentence splitting, part-of-speech tagging, lemmarization, named entity recoginition, and parsing. However sometimes, we use others ...

Read More »

Pass Streams Instead of Lists

java-logo

Opening disclaimer: this isn’t always a good idea. I’ll present the idea, along with some of the reasons why it’s a good idea, but then I’ll talk about some instances where it’s not so great. Being Lazy As you may know, I’ve been dabbling in Python nearly as much as I’ve been working with Java. One thing that I’ve liked ...

Read More »

Simplifying JAX-RS caching with CDI

java-interview-questions-answers

This post explains (via a simple example) how you can use CDI Producers to make it a little easier to leverage cache control semantics in your RESTful services The Cache-Control header was added in HTTP 1.1 as a much needed improvement over the Expires header available in HTTP 1.0. RESTful web services can make use of this header in order ...

Read More »

Starting out with jHiccup

java-logo

After writing my post on ‘How to detect and diagnose slow code in production’ I was encouraged by a reader to try out jHiccup from Azul systems. Last year I went to a talk by jHiccup’s creator Gil Tene on the correct way to measure latency, where, amongst other things, he introduced us to jHiccup. It had been on my todo ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Advanced Java Guide
  • Java Design Patterns
  • JMeter Tutorial
  • Java 8 Features Tutorial
  • JUnit Tutorial
  • JSF Programming Cookbook
  • Java Concurrency Essentials