How to create and modify environment variables on windows?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. 3. On the Advanced tab, click Environment Variables. 4. Click Edit to modify an existing environment variable. 5. After creating or modifying the environment variable, click Apply and then OK to have the change take effect. Information ! If you don’t have JAVA_HOME […]

(SOLVED) What does ‘synchronized’ mean ?

synchronized methods enable a simple strategy for preventing thread interference and memory consistency errors: if an object is visible to more than one thread, all reads or writes to that object’s variables are done through synchronized methods. The synchronized keyword is all about different threads reading and writing to the same variables, objects and resources. […]

(SOLVED) What are the differences between a HashMap and a Hashtable in Java ?

Which is more efficient for non-threaded applications? There are several differences between HashMap and Hashtable in Java: Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones. Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values. One of HashMap’s subclasses is LinkedHashMap, so in the event that you’d want predictable iteration order […]

What is a StackOverflow Error ?

Parameters and local variables are allocated on the stack (with reference types, the object lives on the heap and a variable in the stack references that object on the heap). The stack typically lives at the upper end of your address space and as it is used up it heads towards the bottom of the address space (i.e. towards zero). Your process also […]

java.lang.OutOfMemoryError : How to simulate in Java

In this Topic we will try to simulate the java.lang.OutOfMemoryError !! We will create an object holding 1MB of bytes, add it into a List, and repeat the create and add process until the JVM throw OutOfMemoryError. java.lang.OutOfMemoryError: Java heap space This example will run a while then it will throws java.lang.OutOfMemoryError. The Output : […]

(SOLVED) convert String to Date in Java ?

In this tutorial, we will show you how to convert a String to java.util.Date. Many Java beginners Always find this problem of Date conversion. so we decided to post this solution !! let understand how to convert String Date in JAVA. java.text.SimpleDateFormat provide many date and time patterns : Letter Description Examples y Year 2013 […]

(SOLVED) how to Convert File to Path in Java ?

In this tutorial , we will see how we can convert file to path using Java ? The java.nio.file package includes Java virtual machine interfaces and classes for accessing files, file attributes, and file systems. Convert File to Path If we want to convert from to java.nio.file.Path we can use toPath() Convert Path to […]

JAVA Map , HashMap , LinkedHashMap, TreeMap

Java Map : There are no duplicate values allowed in the map. A map object’s keys must be unique. HashMap, TreeMap, and LinkedHashMap are three groups that implement the Map interface in the Java collection system. SortedMap is a special interface for keeping all of the elements sorted. HashMap vs LinkedHashMap The ordering of the […]

Different ways iterate a list in Java

Iterate a list in Java : in this Post we will discover different ways to browse a list in Java. (ArrayList) List.toString() If we want to iterate over a list in java , we can do that by converting the list to a string using the toString() function, then outputting it Output : Using For […]

Difference between ArrayList and LinkedList in Java

ArrayList vs LinkedList : Both ArrayList and LinkedList implement the List interface, but what’s the difference then ? The main difference between ArrayList and LinkedList is in ArrayList which is implemented using an extensible array. As more items are added to ArrayList, its size dynamically increases. Its elements can be accessed directly using the get() […]

Comparator example Java 8 Lambda expression

We’ll show you how to write a Comparator to sort a List using Java 8 Lambda expressions in this example. Classic Comparator example Lambda expression equivalent. Sort without Lambda A comparison of Developer objects based on their age is an example. Normally, you use Collections.sort and pass an anonymous Comparator class like this : Output […]

(SOLVED) Minimum number of increment

Minimum number of increment, We’ve been given an array of n components. You can choose any one element and increase the rest of the n-1 elements by one at each operation. You must make all elements equal and replicate the process as many times as you like. Determine the smallest number of operations required. Examples: […]

How to convert List to int[] in Java ?

List<Integer> to int[] To convert List<Integer> to int[] in java we can use les Streams, With Java 8, int[] can be converted to Integer[] easily : Integer[] is generally not a good map key, as others have said. However, we now have a reasonably clean and native code in terms of conversion. Also read , […]