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

 

 

You cannot override a method just by using the same name

In this example we shall show you why you cannot override a method just by using the same name. We are using two classes as described below: Class A has a method, char func(char a) that returns a char value. It also has a method, float func(float f) that returns a float value. Class Bart extends A and has a method, ...

Read More »

Use inner class for callbacks

With this example we are going to demonstrate how to use inner class for callbacks to a class. The example is described in short: We have created an interface, Incrementable and a class to implement it, Callee1. It has a method increment(), that increases an int value.  We have also created a class, MyIncrement that consists of a method increment() ...

Read More »

Static inner class example

This is an example of how to use a static inner class. We have set the example as described below: We have created a class, ArAlgo that contains a static inner class P. Class P has two double attributes and their getters. ArAlgo class also has a static method, P min_max(double[] vals). The method gets a double array and for ...

Read More »

Anonymous inner class constructor

This is an example of how to use an anonymous inner class. We have set an example following the above steps: We have created an abstract class, Abs that has a constructor and an abstract method. We have also created another class, InnerClassConst, that has a static method, getAbs(int i), that returns a new Abs, for a given int value, where ...

Read More »

Inner class reference

With this example we are going to demonstrate how to make an inner class reference. In short, to make an inner class reference we have followed the above steps: We have created a class InnerClassRef, that contains an inner class C and another inner class D. Class C has a method value() that returns an int value. Class D has ...

Read More »

Creating inner class example

This is an example of how to create an inner class. In short, to create an inner class we have performed the following steps: We have created a class CreatingInner that contains two inner classes, Contents and Destination. Contents class has a method value() and Destination class has a constructor using a String field and a method readLabel(). CreatingInner class ...

Read More »

Nested class examples

In this example we shall show you how to create a nested class. To create a nested class we have performed the following steps: We have created class MN that has a method f() and an inner class A. Class A has also a method g() and another class B. Class has a method h() that calls g() method of A ...

Read More »

Initialization order example

With this example we are going to demonstrate what happens when there are changes in the initialization order of classes. The steps of the example are described in short: We have created class A, with a constructor that gets an int val and prints it. We have also created class Cr. In the Cr we use the A constructor to ...

Read More »

Static array shared between class instances

This is an example of how to create a static array shared between class instances. The example is described in short below:  We have created a class, SharedArray, that has a static int array, initialized with length 10. In a static block, the array is initialized with random int values, using random() API method of Math. The class also has ...

Read 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 »