Core java
08 FebruaryPrint Classpath in Java
In this post, we will see how to print CLASSPATH in java. 💡 Outline You can use System.getProperty("java.class.path") to get ClassPath in java. String classpath = System.getProperty("java.class.path"); String[] classPathValues = classpath.split(File.pathSeparator); System.out.println(Arrays.toString(classPathValues)); What is CLASSPATH in java CLASSPATH variables tell application to location where it should find user classes. Default CLASSPATH is current working directory(.). […]
07 FebruaryGet Unicode Value of Character in Java
In this post, we will see how to get unicode value of character in java. Get Unicode Value of Character in Java You can simply use below code to get unicode value of character in java. private static String getUnicodeCharacterOfChar(char ch) { return String.format("\\u%04x", (int) ch); } Here is complete example to print unicode value […]
07 FebruaryGet number of days in Month in java
Learn about how to get number of days in Month in java. Get number of days in Month in java Using YearMonth’s lengthOfMonth() [Java 8] You can use YearMonth‘s lengthOfMonth() method to get number of days in Month in java. Pass Year and month to YearMonth’s of and create YearMonth object. Call lengthOfMonth() on YearMonth’s […]
04 FebruaryGet last day of Month in java
Learn about how to get last day of month in java. There are times when you need to get last day of month to process data at the end of each month. For example: Processing salaries of the employee in your company. There are multiple ways to get last day of month in java Ways […]
02 FebruaryFind Character in String in Java
In this post, we will see how to find character in String in java. How to Find Character in String in Java There are multiple ways to find char in String in java 1. Using indexOf() Method to Find Character in String in Java indexOf() method is used to find index of substring present in […]
02 FebruaryRemove Comma from String in Java
Learn about how to remove comma from String in java. Remove comma from String in java 1. Using replace() method You can use String’s replace() method to remove commas from String in java. Here is syntax of replace method: public String replace(CharSequence target, CharSequence replacement) package org.arpit.java2blog; public class RemoveCommaFromStringMain { public static void main(String[] […]
31 JanuaryHow to Print Multiple Variables in Java
1. Introduction In Java programming, it’s common to need to print multiple variables for various purposes like debugging, logging, or displaying information to the user. These variables might be of different data types (such as integers, strings, or floats), and our goal is to effectively combine and display them. The expected output is a coherent […]
25 JanuaryCreate ArrayList of Objects in Java
In this tutorial, we will learn how to create ArrayList of objects in Java. We will create a Book class with different properties and use it to create custom book objects when creating an ArrayList of objects. We will filter these book objects using certain criteria and add the book objects that meet the criteria […]
15 JanuarySplit String by pipe(|) in java
In this post, we will see how to split String by pipe in java. How to split String by pipe in java There are multiple ways to split String by pipe (|) in Java. Using split() method You can use String’s split() method to split String by pipe in java. Let’s say you want to […]