What Does the Method contains(obj o) Do in Java

Nikitha N
Updated on 25-Feb-2020 08:20:14

133 Views

The contains(Object) method of the java.util.ArrayList class returns true if this list contains the specified element.Exampleimport java.util.ArrayList; public class ArrayListDemo {    public static void main(String[] args) {       ArrayList arrlist = new ArrayList

What is the Java Runtime Environment (JRE)

Ayyan
Updated on 25-Feb-2020 08:19:34

518 Views

JRE is Java Runtime Environment and is the machine-specific implementation of JVM. It contains libraries like rt.jar, class loaders etc which are used by JVM.

Find Common Elements Between Two Vectors Using STL in C++

Ayush Gupta
Updated on 25-Feb-2020 08:05:48

955 Views

In this tutorial, we will be discussing a program to understand how to find common elements between two vectors using STL in C++.To find the common elements between two given vectors we will be using the set_intersetion() method.Example Live Demo#include using namespace std; int main(){    //defining the vectors    vector vector1 = { 1, 45, 54, 71, 76, 12 };    vector vector2 = { 1, 7, 5, 4, 6, 12 };    sort(vector1.begin(), vector1.end());    sort(vector2.begin(), vector2.end());    cout

Find Common Elements Between Two Arrays Using STL in C++

Ayush Gupta
Updated on 25-Feb-2020 07:59:32

269 Views

In this tutorial, we will be discussing a program to understand how to find common elements between two arrays using STL in C++.To find the common elements between two given arrays we will be using the set_intersetion() method.Example Live Demo#include using namespace std; int main(){    //defining the array    int arr1[] = { 1, 45, 54, 71, 76, 12 };    int arr2[] = { 1, 7, 5, 4, 6, 12 };    int n1 = sizeof(arr1) / sizeof(arr1[0]);    int n2 = sizeof(arr2) / sizeof(arr2[0]);    sort(arr1, arr1 + n1);    sort(arr2, arr2 + n2);    cout

Draw Circle in HTML Page

Smita Kapse
Updated on 25-Feb-2020 07:51:53

10K+ Views

To draw a circle in HTML page, use SVG or canvas. You can also draw it using CSS, with the border-radius property.ExampleYou can try to run the following code to learn how to draw a circle in HTMLLive Demo                    #circle {             width: 50px;             height: 50px;             -webkit-border-radius: 25px;             -moz-border-radius: 25px;             border-radius: 25px;             background: blue;          }                        

Work with Scalable Vector Graphics (SVG) in HTML5

Nishtha Thakur
Updated on 25-Feb-2020 07:50:58

350 Views

SVG stands for Scalable Vector Graphics and it is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer.SVG is mostly useful for vector type diagrams like Pie charts, Two-dimensional graphs in an X, Y coordinate system etc.To work with Scalable Vector Graphics (SVG) in HTML5, embed SVG directly using ... tags with the following syntax −Syntax    ... To draw a shape in HTML5 SVG, use element to draw a circle. element to draw a rectangle. element to draw a line. element to draw and ellipse. element to draw ... Read More

Create Unordered Set of User-Defined Class or Struct in C++

Ayush Gupta
Updated on 25-Feb-2020 07:49:36

791 Views

In this tutorial, we will be discussing a program to understand how to create an unordered set of user defined class or struct in C++.For this we will create a structure type and then compare two structure types with the function defined by the user to store the hash function.Example#include using namespace std; //defined structure struct Test {    int id;    bool operator==(const Test& t) const{       return (this->id == t.id);    } }; //defined class for hash function class MyHashFunction {    public:       size_t operator()(const Test& t) const{         ... Read More

Play Sound File in a Web Page in the Background

Smita Kapse
Updated on 25-Feb-2020 07:37:38

25K+ Views

The HTML element is used to add audio to web page. To play sound file in the background on a web page, use the … element. Also, use the autoplay attribute. This will run music in the background whenever the page loads.Set the width and height in a way the player hides on the web page. The loop attribute is added to specify whether the audio will start over again.You can try to run the following code to play a sound file in a web page in the backgroundExampleLive Demo           HTML background music ... Read More

Create Unordered Map of User-Defined Class in C++

Ayush Gupta
Updated on 25-Feb-2020 07:36:24

609 Views

In this tutorial, we will be discussing a program to understand how to create an unordered map of user defined class in C++.To create an unordered map from a user defined class, we will pass the hash function as the class method being the third argument.Example Live Demo#include using namespace std; //objects of class to be used as key values struct Person {    string first, last;    Person(string f, string l){       first = f;       last = l;    }    bool operator==(const Person& p) const{       return first == p.first && ... Read More

Create Unordered Map of Pairs in C++

Ayush Gupta
Updated on 25-Feb-2020 07:31:23

927 Views

In this tutorial, we will be discussing a program to understand how to create an unordered map of pairs in C++.Unordered maps are the ones that don't contain hash function for the pairs by default. If we want a hash value for a particular pair, it needs to be passed on explicitly.Example Live Demo#include using namespace std; //to hash any given pair struct hash_pair {    template    size_t operator()(const pair& p) const{       auto hash1 = hash{}(p.first);       auto hash2 = hash{}(p.second);       return hash1 ^ hash2;    } }; int main(){ ... Read More

Advertisements