The Location pathname property returns/sets the string corresponding to the URL pathname.SyntaxFollowing is the syntax −Returning value of the pathname propertylocation.pathnameValue of the href property setlocation.pathname = pathOfHostExampleLet us see an example for Location pathname property − Live Demo Location pathname form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } Location-pathname Current URL: var divDisplay = document.getElementById("divDisplay"); var urlSelect = document.getElementById("urlSelect"); function getpathname(){ divDisplay.textContent = 'URL pathname: '+location.pathname; } OutputThis will produce the following output −Before clicking ‘Get pathname’ button −After clicking ‘Get pathname’ button −
In this section, we will see how to use the catch block for exception handling and the type conversion in C++.At first, let us see a code, and we will see what will be the output, and how they are generating.Example#include using namespace std; int main() { try{ throw 'a'; } catch(int a) { cout
To create high precision timer we can use the chrono library. This library has high resolution clock. This can count in nanoseconds.In this program we will see the execution time in nanoseconds. We will take the time value at first, then another time value at the last, then find the difference to get elapsed time. Here we are using blank loop to pause the effect for sometimes.Example#include #include typedef std::chrono::high_resolution_clock Clock; main() { auto start_time = Clock::now(); for(int i = 0; i
Yes, you can achieve this using aggregate framework. Let us first create a collection with documents −> db.sliceOfSliceDemo.insertOne( ... { ... "Name": "John", ... "Details": [["First 1:1", "First 1:2"], ["second 2:1", "Second 2:2"]] ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5ccf3fcfdceb9a92e6aa195a") }Following is the query to display all documents from a collection with the help of find() method −> db.sliceOfSliceDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5ccf3fcfdceb9a92e6aa195a"), "Name" : "John", "Details" : [ [ "First ... Read More
A thread-safe class is a class that guarantees the internal state of the class as well as returned values from methods, are correct while invoked concurrently from multiple threads.The HashMap is a non-synchronized collection class. If we need to perform thread-safe operations on it then we must need to synchronize it explicitly.Example:import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Iterator; public class HashMapSyncExample { public static void main(String args[]) { HashMap hmap = new HashMap(); hmap.put(2, "Raja"); hmap.put(44, "Archana"); hmap.put(1, "Krishna"); ... Read More
For this, you can use COLLATE. Following is the syntax −select *from yourTableName where yourColumnName LIKE yourValue COLLATE utf8_bin;Let us first create a table −mysql> create table DemoTable ( LastName varchar(100) ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Brown'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('BROWN'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable values('brown'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('BRoWN'); Query OK, 1 row affected (0.14 sec)Display all records ... Read More
Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double and, reference datatypes (arrays and objects).Casting in JavaConverting one primitive data type into another is known as type casting. There are two types of casting −Widening− Converting a lower datatype to a higher datatype is known as widening. It is done implicitly.Narrowing− Converting a higher datatype to a lower datatype is known as narrowing. You need to do it explicitly using the cast operator (“( )”).For every primitive variable a wrapper class is available, ... Read More
Here we will see how we can concatenate a string n number of times. The value of n is given by the user. This problem is very simple. In C++ we can use + operator for concatenation. Please go through the code to get the idea.AlgorithmconcatStrNTimes(str, n)begin res := empty string for i in range 1 to n, do res := concatenate res and res done return res endExample Live Demo#include using namespace std; main() { string myStr, res = ""; int n; cout > myStr; cout > n; for(int i= 0; i < n; i++) { res += myStr; } cout
The Location port property returns/sets the port number (if specified) for a URL. Port number might not get displayed if not explicitly specified.SyntaxFollowing is the syntax −Returning value of the port propertylocation.portValue of the port property setlocation.port = portNumberExampleLet us see an example for Location port property − Live Demo Location port form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } ... Read More
Here we will see three functions. These functions are Rint(), rintf() and the rintl(). These functions are used to convert floating point values into rounded format.The rint() FunctionThis function is used for rounding floating point value to integer. The syntax is like below. If the result is outside of return type, the domain error may occur. When the argument is 0 or infinity, then it will return unmodifiedfloat rint(float argument) double rint(double argument) long double rint(long double argument)Example#include #include using namespace std; main() { double a, b, x, y; x = 53.26; y = 53.86; ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP