Home » Archives for 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 »

Comparator Java Example

In this post, we feature a comprehensive article on Comparator Java. 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, ...

Read More »

Java SimpleDateFormat Example

In this example we will show how to use the Java SimpleDateFormat class – java.text.SimpleDateFormat , 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

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

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 »

Java read file Example

In this example we will show how to open and read a file in Java. There are many ways to do this, but we will show two of them. For this example, we will read the contents of a text file named “test_file.txt”. 1. Read a file using BufferedReader This is the most commonly-used method in order to read a ...

Read More »

Java static class Example

In this example, we will discuss about static classes in Java. First of all, let’s give a short explanation of the static modifier. For example, if a field or a method in a class has the static modifier in its declaration , then it is always associated with the class as a whole, rather than with any object of the ...

Read More »