Samual Sam has Published 2492 Articles

Remove an element from a Queue in Java

Samual Sam

Samual Sam

Updated on 25-Jun-2020 10:35:55

2K+ Views

To remove an element from a Queue, use the remove() method.First, set a Queue and insert some elements −Queue q = new LinkedList(); q.offer("abc"); q.offer("def"); q.offer("ghi"); q.offer("jkl"); q.offer("mno"); q.offer("pqr"); q.offer("stu"); q.offer("vwx");Remove the first element −System.out.println("Queue head = " + q.element()); System.out.println("Removing element from queue = " + q.remove());The following is ... Read More

Get the last element from a Sorted Set in Java

Samual Sam

Samual Sam

Updated on 25-Jun-2020 10:33:48

2K+ Views

To create a Sorted Set, firstly create a Set −Set s = new HashSet();Add elements to the above set −int a[] = {77, 23, 4, 66, 99, 112, 45, 56, 39, 89}; Set s = new HashSet(); try {    for(int i = 0; i < 5; i++) {   ... Read More

Check whether a Stack is empty or not in Java

Samual Sam

Samual Sam

Updated on 25-Jun-2020 10:30:57

3K+ Views

The method java.util.Stack.empty() is used to check if a stack is empty or not. This method requires no parameters. It returns true if the stack is empty and false if the stack is not empty.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Stack; public class Demo { ... Read More

DataView.getInt8() function in JavaScript

Samual Sam

Samual Sam

Updated on 25-Jun-2020 10:28:09

27 Views

The getInt8() function of the DataView gets and returns a signed 8-bit floating point number at the specified position.SyntaxIts syntax is as followsdataView.getInt8();Example Live Demo    JavaScript Example           var arrayBuffer = new ArrayBuffer(20);       var dataView = new DataView(arrayBuffer);     ... Read More

DataView.getUint16() function in JavaScript

Samual Sam

Samual Sam

Updated on 25-Jun-2020 10:27:22

31 Views

The getUint16() function of the DataView gets and returns an unsigned 16-bit integer at the specified position.SyntaxIts syntax is as followsdataView.getUint16();Example Live Demo    JavaScript Example           var arrayBuffer = new ArrayBuffer(20);       var dataView = new DataView(arrayBuffer);       dataView.setUint16(1, ... Read More

Java IdentityHashMap containsValue() method

Samual Sam

Samual Sam

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

49 Views

Use the containsValue() method to check for the existence of a value. First, create a IdentityHashMap −Map m = new IdentityHashMap();Add some elements −m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110); m.put("6", 50); m.put("7", 90); m.put("8", 250); m.put("9", 350); m.put("10", 450);Now check for the existence of a value ... Read More

DataView.getUint8() function in JavaScript

Samual Sam

Samual Sam

Updated on 25-Jun-2020 10:25:53

38 Views

The getUint8() function of the DataView gets and returns an unsigned 8-bit integer at the specified position.SyntaxIts syntax is as followsdataView.getUint8();Example Live Demo    JavaScript Example           var arrayBuffer = new ArrayBuffer(20);       var dataView = new DataView(arrayBuffer);       dataView.setUint8(1, ... Read More

Get the location of an element in Java ArrayList

Samual Sam

Samual Sam

Updated on 25-Jun-2020 10:25:43

2K+ Views

The location of an element in an ArrayList can be obtained using the method java.util.ArrayList.indexOf(). This method returns the index of the first occurrence of the element that is specified. If the element is not available in the ArrayList, then this method returns -1.A program that demonstrates this is given ... Read More

DataView.setInt32() function in JavaScript

Samual Sam

Samual Sam

Updated on 25-Jun-2020 10:24:25

25 Views

The setInt32() function of the DataView stores a signed 32-bit integer at the specified position.SyntaxIts syntax is as followsdataView.setInt32();Example Live Demo    JavaScript Example           var arrayBuffer = new ArrayBuffer(20);       var dataView = new DataView(arrayBuffer);       dataView.setInt32(1, 36274722);   ... Read More

DataView.setUint16() function in JavaScript

Samual Sam

Samual Sam

Updated on 25-Jun-2020 10:22:51

42 Views

The setUint16() function of the DataView stores an unsigned 16-bit integer at the specified position.SyntaxIts syntax is as followsdataView.setUint16();Example Live Demo    JavaScript Example           var arrayBuffer = new ArrayBuffer(20);       var dataView = new DataView(arrayBuffer);       dataView.setUint16(1, 45544);   ... Read More

Advertisements