The keys() function of typedArray object is similar to entries but, it returns an iterator object containing the indices of the typed array.SyntaxIts Syntax is as followstypedArray.keys()Example Live Demo JavaScript Array every Method var int32View = new Int32Array([21, 64, 89, 65, 33, 66, 87, 55]); document.write("Contents of the typed array: "+int32View); document.write(""); var it = int32View.keys(); for(i=0; i
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. If the array doesn’t contain the specified element the indexOf() function returns -1.SyntaxIts Syntax is as followstypedArray.lastIndexOf(50)Example Live Demo JavaScript Array every Method var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55, 66, 97, 66 ]); ... Read More
Let’s say the following is our string.THIS IS DEMO TEXT!Here, to replace every occurrence of ‘I’ with ‘E’, use the replace() method.str.replace('I', 'E'));The following is the complete example to replace all occurrences of a given character with new character.Example Live Demopublic class Demo { public static void main(String[] args) { String str = "THIS IS DEMO TEXT!"; System.out.println("String = "+str); System.out.println("Updated string = "+str.replace('I', 'E')); } }OutputString = THIS IS DEMO TEXT! Updated string = THES ES DEMO TEXT!
In MySQL, auto increment counter starts from 0 by default, but if you want the auto increment to start from another number, use the below syntax.ALTER TABLE yourTable auto_increment=yourIntegerNumber;To understand the above syntax, let us first create a table. The query to create a table is as follows.mysql> create table startAutoIncrement -> ( -> Counter int auto_increment , -> primary key(Counter) -> ); Query OK, 0 rows affected (0.90 sec)Implement the above syntax to begin auto increment from 20. The query is as follows.mysql> alter table startAutoIncrement auto_increment=20; Query OK, 0 rows affected (0.30 sec) Records: 0 Duplicates: 0 Warnings: ... Read More
The map() function of the TypedArray object accepts the name of a function and calls it on every element of the typed array and returns the results.SyntaxIts Syntax is as followstypedArray.map()Example Live Demo JavaScript Array every Method var int32View = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]); document.write("Contents of the typed array: "+int32View); document.write(""); function square(ele) { return ele*ele; } var result = int32View.map(square); document.write("Specified element occurred at the index: "+result); OutputContents of the typed array: 11,5,13,4,15,3,17,2,19,8 Specified element occurred at the index: 121,25,169,16,225,9,289,4,361,64
To rotate elements of a collection in Java, we use the Collections.rotate() method. The rotate method rotates the elements specified in the list by a specified distance. When this method is invoked, the element at index x will be the element previously at index (x - distance) mod list.size(), for all values of i between 0 and list.size()-1, inclusive.Declaration − The java.util.Collections.rotate() is declared as follows -public static void rotate(List list, int distance)Let us see a program to rotate elements of a collection in Java -Example Live Demoimport java.util.*; public class Example { public static void main(String[] args) { ... Read More
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 first occurrence of “IS” is replaced.Example Live Demopublic class Demo { public static void main(String[] args) { String str = "THIS IS DEMO TEXT!"; System.out.println("String = "+str); System.out.println("Replacing only the first occurrence of substring IS..."); System.out.println("Updated string = ... Read More
In order to sort items of an ArrayList with Collections.reverseOrder() in Java, we need to use the Collections.reverseOrder() method which returns a comparator which gives the reverse of the natural ordering on a collection of objects that implement the Comparable interface.Declaration − The java.util.Collections.reverseOrder() method is declared as follows -public static Comparator reverseOrder()Let us see a program to sort an ArrayList with Collections.reverseOrder() in Java -Example Live Demoimport java.util.*; public class Example { public static void main (String[] args) { ArrayList list = new ArrayList(); list.add(10); list.add(50); ... Read More
Use the grid-auto-flow property to include auto-placed items in the grid.ExampleYou can try to run the following code to implement the grid-auto-flow property with CSS −Live Demo .container { display: grid; grid-auto-columns: 50px; grid-auto-flow: column; grid-gap: 10px; background-color: red; padding: 10px; } .container>div { background-color: yellow; text-align: center; padding:10px 0; font-size: 20px; } 1 2 3 4 5 6
The array is cyclically rotated clockwise by one. This means that each of the array elements are displayed to the right by one and the last element ends up as the first element. An example of this is given as follows.Original array = 1 2 3 4 5 6 7 8 9 10 Rotated array = 10 1 2 3 4 5 6 7 8 9A program that demonstrates this is given as follows.Example Live Demopublic class Example { public static void main(String[] args) { int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP