Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Arushi
Page 4 of 9
Difference between HashMap and ConcurrentHashMap in Java
Following are the notable differences between HashMap and ConcurrentHashMap classes in Java. HashMapConcurrentHashMapSynchronizedHashMap is not synchronized.ConcurrentHashMap is synchronized.Thread SafeHashMap is not thread safe.ConcurrentHashMap is thread safe.Iterator typeHashMap iterator is fail-fast and ArrayList throws ConcurrentModificationException if concurrent modification happens during iteration.ConcurrentHashMap is fail-safe and it will never throw ConcurrentModificationException during iteration.Null valuesHashMap allows key and value to be null.ConcurrentHashMap does not allow null key/value. It will throw NullPointerException.PerformanceHashMap is faster.ConcurrentHashMap is slower than HashMap.Since Java Version1.21.5Exampleimport java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; public class Tester { public static void main(String[] args) { List arrayList = new ArrayList(); ...
Read MoreWhile fetching the data as output, how can I use multiple conditions on same column?
Followings are the ways in which we can write a query that returns only records that matches multiple conditions on the same columnBy using ‘OR’ logical operatorAs we know that MySQL ‘OR’ operator compares two expressions and returns TRUE if either of the expression is TRUE. Following example demonstrate that how we can use ‘OR’ operator for multiple conditions on the same columnmysql> Select * from Student WHERE Name = 'Gaurav' OR Name = 'Aarav'; +------+--------+---------+-----------+ | Id | Name | Address | Subject | +------+--------+---------+-----------+ | 1 | Gaurav | Delhi | Computers ...
Read MoreWhat happens if I will try to drop PRIMARY KEY constraint from the AUTO_INCREMENT column?
As we know the AUTO_INCREMENT column must have the PRIMARY KEY constraint on it also hence when we will try to drop PRIMARY KEY constraint from the AUTO_INCREMENT column the MySQL returns an error message regarding the incorrect table definition. The example below will demonstrate it −ExampleSuppose we have ‘Accounts’ table having the following description −mysql> Describe accounts; +--------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+----------------+ | Sr | int(10) | NO | PRI | NULL | auto_increment | ...
Read MoreHow to get time difference between two timestamps in seconds?
To get the time difference between two timestamps, try to run the following code. Here, we are calculating the total number of hours, minutes and seconds between two timestamps − Example JavaScript Dates var date1, date2; date1 = new Date( "Jan 1, 2018 11:10:05" ); document.write(""+date1); date2 = new Date( "Jan 1, 2018 08:15:10" ); document.write("<br>"+date2); var res = Math.abs(date1 - date2) / 1000; // get total days between two dates var days = Math.floor(res / 86400); document.write("<br>Difference (Days): "+days); // get hours var hours = Math.floor(res / 3600) % 24; document.write("<br>Difference (Hours): "+hours); // get minutes var minutes = Math.floor(res / 60) % 60; document.write("<br>Difference (Minutes): "+minutes); // get seconds var seconds = res % 60; document.write("<br>Difference (Seconds): "+seconds); Output Mon Jan 01 2018 11:10:05 GMT+0530 (India Standard Time) Mon Jan 01 2018 08:15:10 GMT+0530 (India Standard Time) Difference (Days): 0 Difference (Hours): 2 Difference (Minutes): 54 Difference (Seconds): 55
Read MoreExamples of Existing Networks
Some of the prominently used networks in today’s world are −InternetIEEE 802.11 for Wireless LANRFID and Sensor NetworksInternetInternet is a global collection of vast number of dissimilar networks that are interconnected together. Internet uses the TCP/IP protocol and provides varied services. The networks forming the Internet may be private, public, academic, commercial or government, but Internet as a whole is not controlled by any one organization. Internet uses a wide range of networking technologies which are being continually upgraded.The traditional services provided by the Internet were electronic mail, file sharing, and hyperlinked documents. The passage of time has been witnessing ...
Read MoreThe Host-to-Network Layer in TCP/IP Model
The host-to-network layer is the lowest layer of the TCP/IP model and is concerned with the physical transmission of data. It is also called a network interface layer or link layer. It can be considered as the combination of physical layer and data link layer of the OSI model.The functions of this layer are −It defines how bits are to be encoded into optical or electrical pulses.It accepts IP packets from the network layer and encapsulates them into frames. It synchronizes the transmission of the frames as well as the bits making up the frames, between the sender and the ...
Read MoreConnectionless Services
A Connectionless service is a data communication between two nodes where the sender sends data without ensuring whether the receiver is available to receive the data. Here, each data packet has the destination address and is routed independently irrespective of the other packets. Thus the data packets may follow different paths to reach the destination. There’s no need to setup connection before sending a message and relinquish it after the message has been sent. The data packets in a connectionless service are usually called datagrams.Protocols for connectionless services are −Internet Protocol (IP)User Datagram Protocol (UDP)Internet Control Message Protocol (ICMP)Connectionless services ...
Read MoreHome Networks
A home network is a small sized LAN that is used to connected devices within the small area of a home. It facilitates sharing of files, peripheral devices, programs and Internet access among the computers in a home. Home networks may be wired, i.e. connections within devices are done with cables; or wireless, i.e. connections are provided using Wi-Fi and Bluetooth.Purpose of Home NetworksModemRouterNetwork SwitchNetwork BridgeHome Automation Controller
Read MoreWhat will happen when { } is converted to String in JavaScript?
Use the String() method in JavaScript to convert to String. You can try to run the following code to learn how to convert { } to String in JavaScript. Example Convert {} to String var myVal = {}; document.write("String: " + String(myVal));
Read MoreWhy do we use the novalidate attribute in HTML?
The novalidate attribute in HTML is used to signify that the form won’t get validated on submit. It is a Boolean attribute and useful if you want the user to save the progress of form filing. If the form validation is disabled, the user can easily save the form and continue & submit the form later. While continuing, the user does not have to first validate all the entries.ExampleYou can try to run the following code to learn how to use novalidate attribute in HTML. In the following example, if you will add text in the field, then it won’t show ...
Read More