Alexandre Dumas was the French author who wrote “The Three Musketeers” historical novel in 1844. This novel got popular because of the adventures, plot and the then political scenario consisting of the issues between Monarchists and Republicans that were discussed. The war between France and England during the time of King Louis XIV was also mentioned in this novel.The Three MusketeersThe three musketeers are actually four, with the protagonist who is the young man named d’Artagnan. He befriends three musketeers named Athos, Porthos and Aramis before joining the elite corps in Paris. This is a well-written novel involving loyalty, betrayal, ... Read More
Get the TreeMap size using the size() method.First, create a TreeMap and add elements to it −TreeMap m = new TreeMap(); m.put(1, "PHP"); m.put(2, "jQuery"); m.put(3, "JavaScript"); m.put(4, "Ruby"); m.put(5, "Java"); m.put(6, "AngularJS"); m.put(7, "ExpressJS");Count the number of elements in the above TreeMap or get the size using the size() method as shown below −m.size()To get the size of TreeMap, the following is the code −Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]) { TreeMap m = new TreeMap(); m.put(1, "PHP"); m.put(2, "jQuery"); ... Read More
To convert the DateTime value into string in MySQL, you can use the DATE_FORMAT() function. The syntax is as follows −select date_format(yourColumnName, ‘%d %m %y’) as anyVariableName from yourTableName;To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table DateAsStringDemo -> ( -> YourDateTime datetime -> ); Query OK, 0 rows affected (0.57 sec)Inserting the date with the help of curdate() method. The query to insert date is as follows −mysql> insert into DateAsStringDemo values(curdate()); Query OK, 1 row affected ... Read More
To concatenate two columns, use CONCAT() function in MySQL. The syntax is as follows −select CONCAT(yourColumnName1, ' ', yourColumnName2) as anyVariableName from yourTableName;To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table concatenateTwoColumnsDemo −> ( −> StudentId int, −> StudentName varchar(200), −> StudentAge int −> ); Query OK, 0 rows affected (1.06 sec)Now you can insert some records in the table. The query to insert records is as follows −mysql> insert into concatenateTwoColumnsDemo values(1, 'Sam', 21); Query OK, 1 row affected (0.18 sec) ... Read More
A range of elements can be removed from a LinkedList by using the method java.util.LinkedList.clear() along with the method java.util.LinkedList.subList(). A program that demonstrates this is given as follows −Example Live Demoimport java.util.LinkedList; public class Demo { public static void main(String[] args) { LinkedList l = new LinkedList(); l.add("Clark"); l.add("Bruce"); l.add("Diana"); l.add("Wally"); l.add("Oliver"); System.out.println("The LinkedList is: ... Read More
Use Iterator class to fetch elements of TreeSet.Create a TreeSet and add elements to itTreeSet set = new TreeSet(); set.add("13"); set.add("11"); set.add("12"); set.add("16"); set.add("19"); set.add("23"); set.add("21"); set.add("20"); set.add("30");Now, to display the elements, use Iterator classIterator i = set.iterator(); while(i.hasNext()){ System.out.println(i.next()); }The following is an example that fetch elements of TreeSet using IterationExample Live Demoimport java.util.*; public class Demo { public static void main(String args[]){ TreeSet set = new TreeSet(); set.add("13"); set.add("11"); ... Read More
Bandwidth delay product is a measurement of how many bits can fill up a network link. It gives the maximum amount of data that can be transmitted by the sender at a given time before waiting for acknowledgment. Thus it is the maximum amount of unacknowledged data.MeasurementBandwidth delay product is calculated as the product of the link capacity of the channel and the round – trip delay time of transmission.The link capacity of a channel is the number of bits transmitted per second. Hence, its unit is bps, i.e. bits per second.The round – trip delay time is the sum ... Read More
A directory can be created with the required abstract path name using the method java.io.File.mkdir(). This method requires no parameters and it returns true on the success of the directory creation or false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo { public static void main(String[] args) { try { File file = new File("c:\demo1\"); file.createNewFile(); boolean flag = file.mkdir(); System.out.print("Directory created? " + flag); } catch(Exception e) { ... Read More
To convert string to date in MySQL, you can use STR_TO_DATE() function. The syntax is as follows −select str_to_date(‘StringValue’, '%d, %m, %Y') as anyVariableName;Apply the above syntax in the following query wherein, we have a string value −mysql> SELECT STR_TO_DATE('26, 11, 2018', '%d, %m, %Y');The following is the output −+--------------------------------------+ | STR_TO_DATE('26, 11, 2018', '%d, %m, %Y') | +--------------------------------------+ | 2018-11-26 | +--------------------------------------+ 1 row in set (0.00 sec)Let us see another example, to ... Read More
Use the containsValue() method to check if a given value exists or not in a HashMap.First, let us create a HashMap and add some elements −HashMap hm = new HashMap(); // Put elements to the map hm.put("Bag", new Integer(1100)); hm.put("Sunglasses", new Integer(2000)); hm.put("Frames", new Integer(800)); hm.put("Wallet", new Integer(700)); hm.put("Belt", new Integer(600));Now let us check whether a given value exist or not. Here, we are checking for the value “800” −hm.containsValue(800);The following is an example to check if a given value exists in a HashMap −Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]) { ... Read More