Intro Dates in programming are hard. The ISO-8601 Date standard made them easier, but to be entirely honest I’m not ISO-8601 Certified, so I’m not very good at my job. What I do know though is the very important difference between YYYY and yyyy when formatting dates. The Difference between yyyy and YYYY According to the DateTimeFormatter Java…
This tutorial shows you how to replace multiple consecutive characters with single character. Consider we have an input as: String str = “%%New%%%%”; Here, there are multiple consecutive occurrence of % character and we can replace its each set of consecutive occurrence as shown below: str = str.replaceAll(“(.)\\1+”,”$1″); So, after performing the above replace operation,…
Autoboxing is an automatic conversion of a primitive type into its corresponding wrapper class object by the java compiler. For an example, converting an int to an Integer. Consider the following example: int i = 10; Integer j = i; Here, Integer j expects wrapper class of Integer object, but even though if we assign…
Question: Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums, return this repeated number. You must solve the problem without modifying the array nums and uses only constant extra space. Example 1: Input: nums =…
A Stream in Java can be defined as a sequence of elements from a source. The source of elements here refers to a Collection or Array that provides data to the Stream. Java streams are designed in such a way that most of the stream operations (called intermediate operations) return a Stream. This helps to create a chain of stream operations. This is…