Karthikeya Boyini has Published 2383 Articles

Replacing Substrings in a Java String

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 13:23:11

113 Views

Let’s say the following is our string.String str = "The Walking Dead!";We want to replace the substring “Dead” with “Alive”. For that, let us use the following logic. Here, we have used a while loop and within that found the index of the substring to be replaced. In this way, ... Read More

TypedArray.join() function in JavaScript

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 13:23:10

36 Views

The join() function of the TypedArray object joins the contents of the typed array as single string and returns it. To this method you can pass a separator to separates the elements of the array.SyntaxIts Syntax is as followstypedArray.join(':')Example Live Demo    JavaScript Array every Method     ... Read More

TypedArray.lastIndexOf() function in JavaScript

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 13:21:29

27 Views

The lastIndexOf() function of the TypedArray object accepts a value and verifies whether the typed array contains the specified element. If so, this function returns the index of the array at which the specified element found, if the element occurred multiple timed this function returns the last index among them. ... Read More

Java Program to replace only first occurrences of given String with new one

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 13:19:35

204 Views

Use the replaceFirst() method to replace only first occurrences of given String with new one.Let’s say we have the following string.String str = "THIS IS DEMO TEXT!";We have to replace the first occurrence of “IS” with “EV”. For that, use replaceFirst() method.str.replaceFirst("IS", "EV");The following is the final example, wherein the ... Read More

TypedArray.name property in JavaScript

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 13:16:32

26 Views

The name property of the TypedArray object represents the name of the typed array in string (format)i.e. one of Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array.SyntaxIts Syntax is as followsFloat32Array.name;Example Live Demo    JavaScript Example           var nameOfarray1 = Float32Array.name;     ... Read More

Add months to current date using Calendar.add() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 13:16:15

4K+ Views

Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date and time.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us increment the months using the calendar.add() method and Calendar.MONTH constant.calendar.add(Calendar.MONTH, 8);Example Live Demoimport java.util.Calendar; public class Demo ... Read More

TypedArray.byteLength property in JavaScript

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 13:15:45

42 Views

The byteLength property of the TypedArray object represents the length of its(in bytes)TypedArray.SyntaxIts Syntax is as followstypedArray.byteLength();Example Live Demo    JavaScript Example           var buffer = new ArrayBuffer(156);       var float32 = new Float32Array(buffer);       document.write(float32.byteLength);     Output156

TypedArray.copyWithin() function in JavaScript

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 13:14:56

36 Views

The copyWithin() function of the TypedArray object copies the contents of this TypedArray within itself. This method accepts three numbers where first number represents the index of the array at which the copying of elements should be started and, the next two numbers represents start and end elements of the ... Read More

Add seconds to current date using Calendar.add() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 13:11:53

2K+ Views

Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date and time.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date and Time = " + calendar.getTime());Now, let us increment the seconds using the calendar.add() method and Calendar.SECOND constant.calendar.add(Calendar.SECOND, 15);Example Live Demoimport java.util.Calendar; public class Demo ... Read More

TypedArray.every() function in JavaScript

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 13:10:46

25 Views

The every() function of TypedArray accepts a string value representing the name of a function, tests whether all the elements in an array passes the test implemented by the provided function.SyntaxIts Syntax is as followstypedArray.every(function_name)Example Live Demo    JavaScript Array every Method           var ... Read More

Advertisements