Java

Spring Framework is developed on two core concepts – Dependency Injection and Aspect-Oriented Programming (AOP). Today we will look into the core concepts of Aspect-Oriented Programming and how we can implement it using Spring Framework. Aspect-Oriented Programming Overview Most of the enterprise applications have some common crosscutting concerns that is applicable for different types of Objects and modules. Some of the common crosscutting concerns are logging, transaction management, data validation, etc.
String Constant Pool is possible only because String is immutable in Java and its implementation of the String interning concept. The string pool is also an example of a Flyweight design pattern. String Pool Examples String s1 = "Hello"; String s2 = "Hello"; String s3 = "Hel" + "lo"; String s4 = "Hel" + new String("lo"); String s5 = new String("Hello"); String s6 = s5.intern(); System.out.println(s1 == s2); // true System.
Differences between wait() and sleep() or sleep() and yield() method in Java Thread is one of the very old questions asked in Java interviews. Though both wait and sleep put threads to the waiting state, they are completely different in terms of behavior and use cases. JavaDoc Definition Thread Class public static void sleep(long millis[, int nanos]) throws InterruptedException Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds plus the specified number of nanoseconds, subject to the precision and accuracy of system timers and schedulers.
An object is a chunk of memory bundled with the code that manipulates memory. In the memory, the object maintains its state (the values of its instance variables), which can change and evolve throughout its lifetime. To get a newly-created object off to a good start, its newly-allocated memory must be initialized to a proper initial state. Here we take an in-depth look at the mechanisms Java uses to manage object initialization.
Most of you will agree that HashMap is a most favorite topic for discussion in interviews nowadays. Now, I am continuing this discussion with you all. I am assuming that if you are interested in the internal working of HashMap, you already know the basics of HashMap, so I’m skipping that part. But if you are new to the concept, follow official java docs. Single Statement Answer If anybody asks me to describe “How HashMap works?
It’s quite straightforward to integrate Log4j into the Spring MVC application. First, include Log4j.jar library into your project dependency, then create a log4.properties file to define the Log4j’s appender and put this file into the project classpath, Done. In the tutorial, we show you how to integrate the Log4j 1.x logging framework into the Spring MVC application. Add Log4j Library to Your Project Download the Log4j library from the official website, or via Maven :
After all the services, DAO, and support classes are tested then it’s time for the controller. Generally, this is hard to test and most developers (based on observation) would rather just test it via Selenium or worse, by hand. That can work but it makes testing logic branches difficult and not to mention it’s time-consuming. Plus no active developer would be willing to wait for browser tests to run before checking in code.
In this tutorial, you will learn how to develop a Spring 4 MVC Hello world example. We hope this tutorial will give you a quick start with Spring MVC development using the latest Spring 4 Release. Technologies used: Spring 4.0.4.RELEASE JDK 1.8 Tomcat 7.0.53 Maven 3.2.1 Eclipse Java EE IDE ( Eclipse Kepler) Maven Project Setup In Eclipse Let us start with the creation of a Maven web project in Eclipse.