• 16 September

    How to Take Integer Input in Java

    This article discusses the methods to take the integer input in Java. Variables In programs, data values are reserved in memory locations that can be identified by names (identifiers). Such named memory location which temporarily reserves data that can be changed while the program is running is called a variable. Let’s see how variables are […]

  • 16 September

    Convert String to Path in Java

    In this post, we will see how to convert String to Path in Java. Using Paths’get() method [ Java 7 ] To convert String to Path, use jva.nio.file.Paths's get() method. It is a static method. Here is an example: [crayon-68c66eb28c194997258298/] Output: [crayon-68c66eb28c19a519540407/] You can also join multiple strings using Paths‘s get() method. It will join […]

  • 15 September

    How to Replace Space with Underscore in Java

    Learn about how to replace space with underscore in java. Replace space with underscore in java 1. Using replace() method Use String’s replace() method to replace space with underscore in java. String’s replace() method returns a string replacing all the CharSequence to CharSequence. Syntax of replace() method: [crayon-68c66eb28c34e648813155/] [crayon-68c66eb28c353640109751/] Output: This_blog_is_Java2blog As you can see, […]

  • 15 September

    How to Replace Comma with Space in Java

    Learn about how to replace comma with space in java. Replace comma with space in java 1. Using replace() method Use String’s replace() method to replace comma with space in java. Here is syntax of replace() method: [crayon-68c66eb28c599620879352/] [crayon-68c66eb28c59d004682464/] Output: 1 2 3 4 As you can see, replace() method replaced each comma with space […]

  • 15 September

    How to Get Temp Directory Path in Java

    In this post, we will see how to get temp directory path in java. Get Temp Directory Path in Java Using System.getProperty() To get the temp directory path, you can simply use System.getProperty("java.io.tmpdir"). It will return default temporary folder based on your operating system. Default temp directory path Windows : %USER%\AppData\Local\Temp Linux/Unix: /tmp Let’s see […]

  • 11 June

    Remove Parentheses From String in Java

    Java uses the Strings data structure to store the text data. This article discusses methods to remove parentheses from a String in Java. Java Strings Java Strings is a class that stores the text data at contiguous memory locations. The String class implements the CharSequence interface along with other interfaces. Strings are a constant data […]

  • 25 May

    Get Variable Name as String in JavaScript

    1. Overview Retrieving a variable’s name as a string in JavaScript can be a handy technique in various programming scenarios, from debugging to dynamic property handling. We’ll explore several methods to convert variable names into strings, covering different use cases. Let’s consider a situation where we have a JavaScript variable, say myVar, and our objective […]

  • 25 May

    Format Date to yyyy-MM-dd in java

    In this post, we will see how to Format Date to yyyy-MM-dd in java. There are multiple ways to format Date to yyyy-MM-dd in java. Let’s go through them. Using DateTimeFormatter with LocalDate (Java 8) To Format Date to yyyy-MM-dd in java: Create a LocalDateTime object. Use DateTimeFormatter.ofPattern() to specify the pattern yyyy-MM-dd Call format() […]

  • 25 May

    Remove Comma from String in JavaScript

    In this post, we will see how to remove comma from String in Javascript. There are multiple ways to do it. Let’s go through them. Using replace() To remove comma from String in Javascript: Use replace() method with regular expression /\,/g as first parameter and empty string as second parameter. [crayon-68c66eb28d43e207852154/] Output: [crayon-68c66eb28d444011050623/] The replace() […]