heartin's blog

Installing And Getting Started With Git

You need to install the version of Git for your system first before getting started. You can download Git for Windows from https://git-for-windows.github.io. A simple Google search will help you install Git.

This is the most important prerequisite for using git in your machine.

 

Tools

You can use various free GUI tools such as Tortoise Git or SourceTree for working with Git easily. 

We will see more about these later, if you face any doubt, please ask.

 

Important Annotations for Spring Core Tasks

This is a quick summary of important annotations in Spring for doing core tasks in Spring. Some of them might have already been covered in examples. Some of them might be covered later. Some of them might be a variation of the already covered ones, so please feel free to try them out and let us know if you face any issues.

 

@Configuration, @Bean

You can use @Configuration to specify a Java configuration file. 

Spring Profiles Introduction

@Profile annotation allow you to register components that will be selected only if its associated profile is active. You can selectively activate a set of beans in a class or all beans .

Specifying base package in spring xml config file

Instead of using @ComponentScan annotation, we can also use <context:component-scan> element in an spring config xml.

spring.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"

Format for Answering Multiple Choice Questions

Please follow the below guidelines for answering questions.

  1. Answer within the question bank itself, without changing the name.

  2. Color your answers with blue color. 

  3. Color your execution results in yellow color. Sometimes you might be asked to first answer without trying out and then actually try compiling/executing it. This step is not mandatory.

[Exercise] Find the middle element of linked list in one Pass

Problem:

Find the middle element of linked list in one Pass.

 

Approach:

You can use the runner technique.  

Two pointers can be used and both will be running at separate speeds. One runner pointer can go in two steps at a time and other pointer can go in one step at a time. Second one will always cover half the distance as that of the other. When one reaches the end, other will be be middle.

Java Keywords and Identifier Naming Rules Quick Reference

This is a quick summary of important keywords and reserved words that you should not be using as an identifier. Identifier is a name given to any class, method, interface, enum or variable that we create. There is also added quick notes section with few important keywords that may be useful for exam or interview preparations.

 

Keywords in Java

  • class, interface, enum(added in 5.0), package, import, new, this,  super, return, void.

Class variables, Instance Variables and Local variables in Java

Based on the scope in which the variable is declared, we can classify variables as Class variables, Instance Variables and Local variables.

 

Class variables (or static variables)

Class variables (or static variables) are declared within a class and outside all methods using the static keyword.

Example: Static variable

class MyClass{

static int myVar;

Creating Composite Keys in Hibernate 4.3

A composite key is a primary key composed of multiple columns.

When you are creating a composite key, your persistent class must override the equals() and hashCode() method. This is required for for Hibernate caching to work correctly. It must also implement the Serializable interface.

Best way to do this is to create a class with all your composite key fields, mark it as @Embeddable and then annotate a field of that class type with @Id in your entity class.

@Embeddable

Entities and Value Types in Hibernate 4.3

An entity is a type on its own and has an existence of its own (e.g. Course, User etc.).

A value type is a type which doesn't have existence of its own, but belongs to an entity (e.g. Address of an User). Value types are always completely owned by their containing entity.

 

Defining entities and value types in Hibernate

Pages

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!