Java Program to Create String from Contents of a File In this program, you’ll learn different techniques to create a string from concents of a given file in Java. Before we create a string from a file, we assume we have a file named test.txt in our src folder. Here’s the content of test.txt This is a Test file. …
Month: April 2021
Java Program to Convert Byte Array to Hexadecimal In this program, you’ll learn different techniques to convert byte array to hexadecimal in Java. Example 1: Convert Byte Array to Hex value public class ByteHex{ public static void main(String[] args){ byte[] bytes = {10, 2, 15, 11}; for (byte b : bytes) { String st …
Java Program to Convert Map (HashMap) to List In this program, you’ll learn different techniques to convert a map to a list in Java. Example 1: Convert Map to List import java.util.*; public class MapList{ public static void main(String[] args){ Map<Integer, String> map = new HashMap<>(); map.put(1, “a”); map.put(2, “b”); map.put(3, “c”); map.put(4, “d”); …
(Binary Classification: Smaller Keras Model in Python with Standardized data) Python Example for Beginners Special 95% discount 2000+ Applied Machine Learning & Data Science Recipes Portfolio Projects for Aspiring Data Scientists: Tabular Text & Image Data Analytics as well as Time Series Forecasting in Python & R Two Machine Learning Fields There are two sides …
(How to do Binary Classification: Keras Model in Python with Standardized data) Python Example for Beginners Special 95% discount 2000+ Applied Machine Learning & Data Science Recipes Portfolio Projects for Aspiring Data Scientists: Tabular Text & Image Data Analytics as well as Time Series Forecasting in Python & R Two Machine Learning Fields There …
Java Program to Get Current Working Directory In this program, you’ll learn to get the current working directory in Java. Example 1: Get current working directory public class CurrDirectory{ public static void main(String[] args){ String path = System.getProperty(“user.dir”); System.out.println(“Working Directory = ” + path); } } Output Working Directory = C:UsersAdminDesktopcurrDir In the above …
Java Program to Convert the ArrayList to an array and vice versa In this example, we will learn to convert the arraylist into an array and vice versa in Java. Example 1: Convert the Arraylist into Array import java.util.ArrayList; class Main{ public static void main(String[] args){ ArrayList<String> languages= new ArrayList<>(); // Add elements in …
Java Program to Join Two Lists In this program, you’ll learn different techniques to join two lists in Java. Example 1: Join Two Lists using addAll() import java.util.ArrayList; import java.util.List; public class JoinLists{ public static void main(String[] args){ List<String> list1 = new ArrayList<String>(); list1.add(“a”); List<String> list2 = new ArrayList<String>(); list2.add(“b”); List<String> joined = new …
Java Program to Add Two Dates In this program, you’ll learn to add two dates in Java using Calendar. Since, Java epoch is 1970, any time represented in a Date object will not work. This means, your Dates will start from 1970 and when two Date objects are added, the sum misses by about 1970 years. So, we …
Java Program to Convert Milliseconds to Minutes and Seconds In the above program, you’ll learn to convert milliseconds to minutes and seconds individually, and together in Java. Example 1: Convert milliseconds to minutes and seconds individually import java.util.concurrent.TimeUnit; public class Milliseconds{ public static void main(String[] args){ long milliseconds = 1000000; // long minutes = …