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

 

 

Inherit inner class example

In this example we shall show you how to inherit an inner class. The following steps describe the example: We have created class A, that has an inner protected class Inner. Class Inner has a constructor and a method that is f(). Class A also has a constructor, a method g() that calls f() method of Inner and a method insertTime(Inner yy) that ...

Read More »

Initializing final fields

With this example we are going to demonstrate how to initialize final fields of a class. In short, to initialize final fields of a class we have followed the below steps: We have created class P, that has a private int attribute and overrides the toString() method of Object to return the String representation of the int value. We have ...

Read More »

Inheritance and constructors example

This is an example of inheritance constructors of classes. The example is described in short below: We have created class A, class B that extends A and CClass that extends B. Each class inherits the constructor of its super class to be initialized. We create a new instance for CClass, using its constructor. Since it inherits B‘s constructor that also inherits A‘s ...

Read More »

IdentityHashcode example

With this example we are going to demonstrate how to get the identity hashcode of a File. Each class in Java inherits hashCode() method from Object class. The identity hashCode is the hashcode that the object of the class would return. In short, to get the identity hashCode of a File you should: Create a few new File instances, by ...

Read More »

Comparing File objects using hashcode example

This is an example of how to compare File objects using the hashcode. Each class in Java inherits hashCode() method from Object class. Comparing File objects using the hashcode implies that you should: Create a few new File instances, by converting the given pathname strings into abstract pathnames.  For each one of the files, use hashCode() API method of File. ...

Read More »

Final arguments to function – Part 2

In this example we shall show you how to use final arguments to a function. To use final arguments to a function we have performed the following steps: We have created a class Giz with a method func(). We have also created a class FinalArguments, that has a method with(final Giz g) and another method without(Giz g). The first method uses a ...

Read More »

Final class example

With this example we are going to demonstrate how to use a final class. In short, to use a final class we have followed the steps below: We have created a final class B, that has two int attributes and an A attribute, that is another class A. It also has an f() method.  We create a new instance of ...

Read More »

Final class fields example

This is an example of how to use final fields in a class, so as to understand the difference between final and non final fields in a class. In short the example is described below: We have created a class FinalFields that has final attributes, such as typical public constants and compile-time constants (private). We create a new instance of ...

Read More »

Final arguments to function

In this example we shall show you how to use final arguments to a function. To use final arguments to a function we have performed the following steps: We have created class FinalArgs, that has run() method and a myFunc(final Calendar d) method. The first method calls the second one, that uses a final Calendar argument and changes the Calendar.YEAR field. ...

Read More »

Full Initialization process

This is an example of a full initialization process in a class. To initialize a class and its fields we have performed the following steps: We have created a class, A, that has a private int x field and a protected int y. It also has a private static int i field that is initialized with a static method print(String), that ...

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:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns