In this tutorial you will see how to write test case on Java thread using junit. Writing junit to test thread in Java will show an example on single threaded environment.
It is advisable to structure the code in such a way so that the code could be easily tested on several distinct areas:
- the code that launches the thread and wait for result.
- the worker code that runs in the thread.
- the concurrency issue may occur when multiple threads are active.
Continue reading “Writing Junit Test on Java Thread”
This tutorial will show you how can you calculate either future date from a particular date to “plus a number of given days” or past date from a particular date to “minus a number of given days”.
Future or past date calculation may be required for various purposes such as to calculate the age of a person on future date or on past date.
I will show you this calculation in Java language. If you need to calculate in PHP please read here https://www.roytuts.com/calculate-future-or-past-date-in-php/ Continue reading “Future or Past Date in Java”
This examples shows how to move all non-zero elements(if any) in an array to the left and all zero elements to the right in the array using Java.
Continue reading “Move Non-Zero Array Elements to Left using Java”
The Josephus problem (or Josephus permutation) is a theoretical problem related to a certain counting-out game.
People are standing in a circle waiting to be executed. Counting begins at a specified point in the circle and proceeds around the circle in a specified direction. After a specified number of people are skipped, the next person is executed. The procedure is repeated with the remaining people, starting with the next person, going in the same direction and skipping the same number of people, until only one person remains, and is freed.
For more information you can read https://en.wikipedia.org/wiki/Josephus_problem
Continue reading “Solving Josephus problem using Java”
Tic-tac-toe (also known as noughts and crosses or Xs and Os) is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game.
For more information on tic-tac-toe please read https://en.wikipedia.org/wiki/Tic-tac-toe
Continue reading “Tic-tac-toe game using Java”
Here I will show you how to configure Jenkins with JDK, GIT and Maven installations. If you need to know setup of Jenkins then please read https://www.jeejava.com/jenkins-setup-in-windows/
Continue reading “Manage Jenkins – Configuring JDK, GIT and Maven”
Test-driven development is related to the test-first programming concepts of extreme programming(https://en.wikipedia.org/wiki/Extreme_programming).
Life cycle of test-driven development
1. Write a test
2. Run the written test
3. Write code that corrects the failing test
4. Clean up your code
5. Go to step 1. Continue reading “TDD – Test Driven Development”
Here we will see how to create a custom HashMap uaing Java language. We have seen the built-in implementation of HashMap in Java API and we know how HashMap works and its usages.
The intention of this example is not to create a rigid HashMap that provides the same functionalities as Java API provides but to give an idea how you can create your own HashMap.
We know also how HashMap works internally and here also we will look into the internal works of HashMap with same basic functionalities.
Continue reading “Creating Custom HashMap in Java”
Here we will see how the huge volume of data in a file can be sorted easily.
You can use tutorial Generate File with Random Content in Java to generate a large text file.
For a smaller file whose contents fit into the memory, sorting the file programmatically can often be as simple as reading the contents of the file into memory and then writing the sorted data back into a file. But a file that is gigabytes in size (for example, 10GB in size), reading all the data into memory as required by traditional programmatic sorting may not be possible for most of the contexts.
Continue reading “Sort large File using Java”
This tutorial will show you how to generate random content for creating a text file using Java technology. We will also use library
wordnet-random-name to generate human friendly random identifiers.
For more information on wordnet-random-name please read https://github.com/kohsuke/wordnet-random-name
Continue reading “Generate File with Random Content in Java”