Home » Author Archives: Konstantina Dimtsa

Author Archives: Konstantina Dimtsa

Konstantina Dimtsa
Konstantina has graduated from the Department of Informatics and Telecommunications in National and Kapodistrian University of Athens (NKUA) and she is currently pursuing M.Sc studies in Advanced Information Systems at the same department. She is also working as a research associate for NKUA in the field of telecommunications. Her main interests lie in software engineering, web applications, databases and telecommunications.

JUnit @Before and @BeforeClass Example

In this example we are going to explain the difference between the @Before and @BeforeClass annotations of JUnit testing framework, using Eclipse IDE. 1. Create JUnit test In this section, we will create the test case that will help us explain the difference between those annotations. Before you create the test class, it is considered as good practice to create ...

Read More »

JUnit RunWith Example

In this example we are going to explain how to run simultaneously more than one test cases using JUnit testing framework and Eclipse IDE. This collection of different test cases that will be executed all together is otherwise called JUnit test suite and for this purpose we use the @RunWith and @Suite annotations. 1. Create the java class to be ...

Read More »

Java CountDownLatch Example

In this example we will discuss about the class java.util.concurrent.CountDownLatch. java.util.concurrent.CountDownLatch is a synchronization mechanism that allows one or more threads to wait until a set of operations being performed in other threads completes. 1. How CountDownLatch works A java.util.concurrent.CountDownLatch is initialized with a given count. The constructor of java.util.concurrent.CountDownLatch is defined as follows:     CountDownLatch(int count) Constructs a ...

Read More »

Java BlockingQueue Example

In this example we will discuss about java.util.concurrent.BlockingQueue interface. java.util.concurrent.BlockingQueue was added in Java 1.5 along with all the other classes and interfaces of java.util.concurrent package. However, what is BlockingQueue and what is the difference with the simple java.util.Queue? How can we use BlockingQueues? Those questions will be answered in the following sections along with a simple example of BlockingQueue's ...

Read More »

Java Comparator Example

Last Updated Jan. 22, 2019 In this example we will show how to use java.util.Comparator interface. java.util.Comparator is an interface which is used for sorting objects in Java. The compare(Object o1, Object o2) method of Comparator interface needs to be implemented for this purpose, which compares two objects and returns an integer, depending on the comparison: positive, if o1 is ...

Read More »

Java SimpleDateFormat Example

Last Updated Jan. 22, 2019 In this example we will show how to use java.text.SimpleDateFormat class so as to convert a Date into a formatted string or a string to a Date. You can make this conversion using the constructors provided by java.text.SimpleDateFormat class and some patterns, such as dd/MM/yyyy, dd-MM-yy and so on, so as to format the Date ...

Read More »

Java Iterator and ListIterator Example

Iterator is a public interface provided by java.util package which belongs to Java Collections Framework. It allows us to traverse a collection such as a List(e.g. ArrayList, LinkedList) or a Set and access the data element of this collection. An Iterator can traverse the collection only in forward direction using next() and hasNext() methods and remove the last element returned ...

Read More »

Java JFrame Example

In this example we will show how to use the class JFrame and how to create a simple gui by using the javax.swing package. JFrame class is one of the containers provided by the java.awt package. Containers in java.awt are components where other components can be located. Another example of a container provided by java.awt is JPanel. So, JFrame works ...

Read More »

Java LinkedList Example

The LinkedList class can be considered as an alternative to ArrayList class. It extends AbstractSequentialList and implements the List interface, with a doubly-linked list. Also, the LinkedList allows the usage of iterators, so that you can iterate the list forwards or backwards and declare the exact position of the starting node. 1. Example of LinkedList Create a java class named ...

Read More »

Java SimpleDateFormat and DateFormat Example

In this example we will show how to use java.text.SimpleDateFormat class so as to format date into text or parse text into date. SimpleDateFormat extends the java.text.DateFormat class which is an abstract class for date/time formatting subclasses and provides many class methods for obtaining default date/time formatters based on any given locale. We will see the usage of the class ...

Read More »