• 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-6a29a94379444362136196/] Output: [crayon-6a29a9437944f079386401/] The replace() […]

  • 25 May

    Escape new line in JavaScript

    In this post, we will see how to escape new line in JavaScript. There is no well known JavaScript library which can escape all special characters in String. Escape new line in JavaScript To escape new line in JavaScript: Use replace() method with regular expression /[\n]/g as first parameter and \\n string as second parameter. […]

  • 23 May

    Escape Ampersand in URL in JavaScript

    In this post, we will see how to escape ampersand in JavaScript. To escape Ampersand in JavaScript, use encodeURIComponent() in JavaScript. [crayon-6a29a9437f270233535836/] Output [crayon-6a29a9437f27b095548038/] As you can see that when we called encodeURIComponent, it encoded & to %26. You can use % to escape characters that aren’t allowed in URLs. Here & is 26 in […]

  • 18 May

    Fill Array With Random Numbers in Java

    The arrays are a commonly used data structure that stores the data in contiguous memory. In this article, you will understand different methods to fill the array with random numbers in Java. We will generate the random numbers using different library methods such as the Java Utility library’s Random class, the Java’s Math class, and […]

  • 18 May

    How to Sum BigDecimal Using Stream in Java

    This article discusses how to sum BigDecimal using stream. One of the significant features in Java 8 is the introduction of stream functionality and a way of carrying out the sum operation on streams of numbers like BigDecimal. BigDecimal objects are immutable like String. Once immutable objects are created they can not be modified. So […]