Convert Instant to ZonedDateTime in JAVA

In this tutorial , we will show a Java 8 example of how to convert from Instant to ZonedDateTime So the output will be : If we need to convert from ZonedDateTime to Instant The output will be : Also read : How to convert String to Date in Java ? References : JavaDoc mkYong

En Lire Plus

(SOLVED) How to get file extension in Java ?

In this tutorial , we will see how we can get the extension of file in Java. In the next example , we will use lastIndexOf to get the file extension of a file. The above process, will fail if the directory name or file path includes a dot or double dots AND the file […]

En Lire Plus

(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 java.io.File to java.nio.file.Path we can use toPath() Convert Path to […]

En Lire Plus

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 […]

En Lire Plus

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() […]

En Lire Plus

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 […]

En Lire Plus

(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: […]

En Lire Plus

Tips to Learn Programming Faster

Tips to Learn Programming Faster The most frequently asked questions today are, “How long does it take to learn Java?” “How can I learn to code quickly and kick-off my career as a software developer?” Not only the freshmen but also a majority of coding auto-didacts are also in search of a quick and straightforward […]

En Lire Plus

Les Bases du langage JAVA [FR]

Introduction Au début des années 90, Sun travaillait sur un projet visant à concevoir des logiciels simples et performants exécutés dans des PDA (Personnal Digital Assistant). Le langage C++ a été retenu pour la programmation de ces logiciels, mais le langage C s’est avéré peu performant , notamment en ce qui concerne la sécurité et […]

En Lire Plus

Java : How to Convert Integer to Binary

In Java, we can use Integer.toBinaryString(int) to convert an Integer to a binary string representative. This article will show you two methods to convert an Integer to a binary string representative. JDK Integer.toBinaryString. Old school bit masking technique. 1. Convert Int to Binary Integer.toBinaryString 1.1 This Java example tries to convert an int to a binary string […]

En Lire Plus

Java : How to Convert Character to ASCII

In Java, we can cast the char to int to get the ASCII value of the char. The explicit cast (int)char is optional, if we assign a char to an integer, Java will auto-cast the char to an int. 1. Convert Char to ASCII This Java example converts a char to an ASCII value, and […]

En Lire Plus

Java vs Python

…most people treat me like idiot for using my head instead of learning 3000 of them for each possible problem. And you’ve hit the nail on the head right there! I concur. The trouble is, almost all Java-related documentation, courses, guides, tutorials, and answers I see advocate certain design patterns, code snippets, and habits (a […]

En Lire Plus

Java : how to convert negative binary to Integer ?

Review the following Java example to convert a negative integer in binary string back to an integer type. The result is NumberFormatException ! The NumberFormatException is due to overflow, the string 11111111111111111111111111111111 (length of 32) are unable to fit into the 32 bits int type ? Note Note Integer has values from -2^31 to 2^31-1 […]

En Lire Plus

Java 15 in 2020

In 2020, Java 15 will be released with major features (some coming out of preview mode), both at language, API, and runtime levels. https://openjdk.java.net/projects/jdk/15/ Considering the changes that have already made through since Java 8 and the upcoming changes in Java 15, what are in your opinion the use cases that no longer make sense […]

En Lire Plus

“Auto increment” alphabet in Java ?

Auto increment alphabet in Java : There is two solution for auto increment alphabet using java : Solution 1 : Solution 2 : It is also possible with typecasting Read also : Java 7 – Java 8 – loop Map / List – forEach examples Read also : Twitter teste une façon de limiter les […]

En Lire Plus

Java : multi-line string, text blocks

Java multi-line string text blocks : This article will show you a few ways to declare and use a multi-line string in Java. String + String + String StringBuilder String.format StringWriter String.join (Java 8) Files.lines (Java 8) (“””) Java 13 and Java 14 text blocks (preview feature) Java multi-line string text blocks : Review an […]

En Lire Plus

(SOLVED) Cannot make a static reference to the non-static method

if you have this error that mean you are using your Repository interface in the place of you using and instance of it ,Exemple : if you have an interface PersonnelRepository and you want to use the function getOne(). if you do like that PersonnelRepository.getOne(id) you will have the error Cannot make a static reference […]

En Lire Plus

Switch Expressions in Java 13

Switch Expressions in Java 13 : In Java 13, the JEP 354: Switch Expressions extends the previous Java 12 Switch Expressions by adding a new yield keyword to return a value from the switch expression. P.S Switch expressions are a preview feature and are disabled by default. 1. No more value breaks! 1.1 Java 12 value breaks syntax is no longer […]

En Lire Plus

Switch Expressions in JAVA 12

Java 12, JEP 325: Switch Expressions enhanced the traditional switch statement to support the following new features: • Multiple case labels • Switch expression returning value via break (replaced with yield in Java 13 switch expressions) • Switch expression returning value via label rules (arrow) P.S Switch expressions are a preview feature and are disabled […]

En Lire Plus

(SOLVED) How to join and split byte arrays, byte[] in JAVA

join and split byte arrays byte[] ? In this example, we will show you how to join and split byte arrays with ByteBuffer and System.arraycopy. ByteBuffer System.arraycopy 1. Join Byte Arrays This Java example uses ByteBuffer or System.arraycopy to join or concatenate two byte arrays. JoinByteArrayExample.java Output Terminal : 2. Split Byte Array In Java, […]

En Lire Plus