How to get user home directory in java for all OS?

How to get user home directory in java for all OS?
DeeKay September 23, 2017 at 10:05 pm · JAVA API

How to get user home directory in java is the common question arises while creating Java/Swing GUI applications. You can get home directory of user using System.getProperty(“user.home”) function. Below java code shows you how to get User home directory. This code will work on Java 1.8 for all OS. Output: There is a bug#JDK-6519127 which…
Continue Reading »


How to convert java.util.Date from java.time.LocalDate?

How to convert java.util.Date from java.time.LocalDate?
DeeKay August 12, 2017 at 3:13 am · JAVA API

The following Java code snippet shows how to convert java.util.Date from java.time.LocalDate  and vice versa. In the first part of the code snippet we convert java.util.Date from java.time.LocalDate and back to LocalDate object. In the second part we convert java.time.LocalDate from java.util.Date and back to java.util.Date object.


How to get Free, Used and Total Memory in Java ?

How to get Free, Used and Total Memory in Java ?
DeeKay June 20, 2017 at 2:02 am · How To, JAVA API

As you know that Java does the automatic garbage collection which you need not worry about. However sometime you want to know how large the java heap space is and how much of it is left. Information about Free, Used and Total memory in java can be used for checking your code efficiency. To obtain…
Continue Reading »


How to convert String to Int in Java ?

How to convert String to Int in Java ?
DeeKay January 20, 2017 at 3:25 am · JAVA API

To convert String to Int in Java, you can use the below methods of Integer class. Methods to convert String to Int 1) Integer.parseInt() code example /** * Created on Nov 19, 2016 Copyright(c) https://kodehelp.com All Rights Reserved. */ package com.kodehelp.java.lang; /** * @author https://kodehelp.com */ public class ConvertStringToInt { public static void main(String args[]){…
Continue Reading »


How to generate pseudorandom numbers in Java ?

How to generate pseudorandom numbers in Java ?
DeeKay January 3, 2017 at 8:45 pm · How To, java.math, java.util, Other

In this post we will see how to generate pseudorandom numbers in Java. Before that we will see what is Random numbers. Random numbers are the numbers that occur in sequence such that the values are uniformly distributed over a defined interval or set, which is impossible to predict future values based on present and…
Continue Reading »


Java 8 – How to find Date on the day of given Week in a month ?

Java 8 – How to find Date on the day of given Week in a month ?
DeeKay December 6, 2016 at 9:17 pm · java.time

In this Java 8 program we will see how to find date on the day of given week in a month. For example if we want to find the date on 3rd Wednesday of current month.  


What is the difference between HashTable and HashMap in Java?

What is the difference between HashTable and HashMap in Java?
DeeKay December 2, 2016 at 3:12 am · java.util

Both HashTable and HashMap are java collections and implements java.util.Map interface. Difference between HashTable and HashMap is the most common interview question. Many of the candidates who face the interview struggle to answer this question. Difference between HashTable and HashMap in Java Thread Safe: HashTable is thread-safe and can be shared between multiple threads but…
Continue Reading »


How to Sort a Map by key in Java?

How to Sort a Map by key in Java?
DeeKay November 20, 2016 at 2:00 am · java.util, sorting

Here we will see how to sort a Map by key in java. There are two ways to sort a Map by Key –   First Approach Second Approach


How to write Bubble Sort in Java ?

How to write Bubble Sort in Java ?
DeeKay September 16, 2014 at 12:58 am · JAVA API, sorting

We all have learnt sorting techniques in our college academic curriculum. Out of those sorting techniques the simplest technique we learnt is Bubble Sort Implementation in Java. The Bubble sort takes an array of numbers and sort them within the array indexes in either ascending or descending order. Bubble sort is simplest of all sorting…
Continue Reading »


How To Send a Plain Text EMail in Java using JavaMail API ?

How To Send a Plain Text EMail in Java using JavaMail API ?
DeeKay May 5, 2014 at 12:28 am · javax.mail

Java Mail API is used to create your own email client. This class provides the code required to model your email client similar to Outlook, Hotmail and many others. In JavaMail you’ll find APIs and provider implementations allowing you to develop fully functional email client applications. Below java program shows you how to send a plain text…
Continue Reading »