It's all about Java

Wednesday, 24 January 2018

Every Java programmer must read books

Every Java programmer must read and understand the following books.


1. Effective Java

2. Concurrency in practice

Effective Java:


This book is authored by Joshua Bloch. He took the major role in authoring the java.util package which is [collection framework] one of the java core libraries.

He explains the best practices that every programmer should consider while writing java programs.

Some of them are:


  • Contract between hashcode() and equals() of Object class when programmer overrides one of these methods in their classes
  • Exceptions
  • concurrency: Inter thread communication, synchronization etc
  • Immutable Objects
The above points are few among others.

Concurrency in practice:


This book gives complete explanation about how efficient concurrency is achieved in java programs using concurrency utility classes which were introduced in Java 5 version.

This book is authored by:

  • Brian Goetz
  • Tim peierls
  • Joshua Bloch
  • Joseph Bowbeer
  • David Holmes and
  • Doug Lea


You can get them from amazon in form of hard copy or soft copy or both. Get them soon. :)
  

Sunday, 21 January 2018

Internals of JVM

Internals of Java Virtual Machine are explained very clearly in the below blog by James Blooms. 


Internals of JVM by James Blooms

Saturday, 30 December 2017

Simple program which demonstrates Swing/AWT Grid layout

Simple program which demonstrates Swing/AWT Grid layout:


This post is intended to the beginners of swing/awt.

This below program creates a JFrame with 2 labels, 2 textfields and 2 buttons.


import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

/**
 * @author Nagasharath Kopalle
 *
 * Simple program to demontrate Gridlayout
 *
 */
public class GridLayoutDemo extends JFrame {

private JLabel labelName = null;

private JTextField textFieldName = null;

private JLabel labelPassword = null;

private JPasswordField passwordFieldPassword = null;

private JButton buttonSubmit = null;

private JButton buttonCancel = null;

/**
*
*/
public GridLayoutDemo() {
initComponents();
}

/**
* instantiates components and adds properties.
*/
void initComponents() {

this.setTitle("Grid Layout Demo");
this.setSize(300, 200);
GridLayout layout = new GridLayout(3, 2);
layout.setHgap(10);
layout.setVgap(5);
labelName = new JLabel("User Name: ");
textFieldName = new JTextField();

labelPassword = new JLabel("Password: ");
passwordFieldPassword = new JPasswordField();

buttonSubmit = new JButton("Submit");
buttonCancel = new JButton("Cancel");

this.setLayout(layout);
this.getContentPane().add(labelName);
this.getContentPane().add(textFieldName);

this.getContentPane().add(labelPassword);
this.getContentPane().add(passwordFieldPassword);

this.getContentPane().add(buttonSubmit);
this.getContentPane().add(buttonCancel);
}

public static void main(String[] args) {

GridLayoutDemo demo = new GridLayoutDemo();
demo.setVisible(true);
}
}

Output:


Popular posts

CHEAT SHEET for java List interface, LinkedList and ArrayList

Consider Below points before choosing List concrete implementations for your use case:  ArrayList is a linear data structure and  re-s...