## Find minimum element of HashSet in Java

Updated on 30-Jul-2019 22:30:24

2K+ Views

To get the minimum element of HashSet, use the Collections.min() method.Declare the HashSet −Set hs = new HashSet();Now let us add the elements −hs.add(29); hs.add(879); hs.add(88); hs.add(788); hs.add(456);Let us now get the minimum element −Object obj = Collections.min(hs);The following is an example to find the minimum element of HashSet −Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]) { // create hash set Set hs = new HashSet(); hs.add(29); hs.add(879); ... Read More

## What are the different shapes of galaxies?

Updated on 30-Jul-2019 22:30:24

399 Views

In the vast space around us, there are numerous galaxies present, which are known as large groups filled with stars, dust, and gases all held together due to gravity. All the galaxies are likely to contain stars, planets, moons, comets, asteroids, black holes, nebulae, dust, neutron stars etc.Just like our solar system that lies in the Milky Way galaxy, there are many galaxies in the space. Every galaxy moves at certain speed and exists in a certain shape. Our milky way galaxy is in the spiral shape with a bright bulge at its center.The famous astronomer Edwin Hubble studied the ... Read More

## Get ceiling key from NavigableMap in Java

Updated on 30-Jul-2019 22:30:24

82 Views

Getting ceiling key means to return the least key greater than or equal to the given key. For this, use the ceilingKey() method.The following is an example to get ceiling key from NavigableMap.Example Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { NavigableMap n = new TreeMap(); n.put(5, "Tom"); n.put(9, "John"); n.put(14, "Jamie"); n.put(1, "Tim"); n.put(4, "Jackie"); ... Read More

## What is algorithm for computing the CRC?

Updated on 30-Jul-2019 22:30:24

5K+ Views

Cyclic Redundancy Check (CRC)Cyclic Redundancy Check (CRC) is a block code that was invented by W. Wesley Peterson in 1961. It is commonly used to detect accidental changes to data transmitted via telecommunications networks and storage devices.CRC involves binary division of the data bits being sent by a predetermined divisor agreed upon by the communicating system. The divisor is generated using polynomials. So, CRC is also called polynomial code checksum.Before sending the message over network channels, the sender encodes the message using CRC. The receiver decodes the incoming message to detect error. If the message is error-free, then it is ... Read More

## A non-static initialization block in Java

Updated on 30-Jul-2019 22:30:24

1K+ Views

Instance variables are initialized using initialization blocks. These blocks are executed when the class object is created and before the invocation of the class constructor. Also, it is not necessary to have initialization blocks in the class.A program that demonstrates a non-static initialization block in Java is given as follows:Example Live Demopublic class Demo {    static int[] numArray = new int[10];    {       System.out.println("Running non-static initialization block.");       for (int i = 0; i < numArray.length; i++) {          numArray[i] = (int) (100.0 * Math.random());       }    }   ... Read More

## SELECT not null column from two columns in MySQL?

Updated on 30-Jul-2019 22:30:24

7K+ Views

There are lots of ways to select NOT NULL column from two columns. The syntaxes are as follows:Case 1: Use IFNULL() function.The syntax is as follows:SELECT IFNULL(yourColumnName1, yourColumnName2) as anyVariableName from yourTableName;Case 2: Use coalesce() function.The syntax is as follows:SELECT COALESCE(yourColumnName1, yourColumnName2) as anyVariableName from yourTableName;Case 3: Use CASE statement.The syntax is as follows:SELECT CASE WHEN yourColumnName1 IS NOT NULL THEN yourColumnName1 ELSE yourColumnName2 END AS anyVariableName FROM yourTableName;Case 4: Use only IF().The syntax is as follows:SELECT IF (yourColumnName1 ISNULL, yourColumnName2, yourColumnName1) AS NotNULLValue FROM SelectNotNullColumnsDemo;To understand the above syntax, let us create a table. The query to create a ... Read More

## Where does MySQL store database files?

Updated on 30-Jul-2019 22:30:24

2K+ Views

To know where MySQL store database files, you can use the variable @@datadir. The query is as follows −mysql> select @@datadir;The following is the output that displays the path −+---------------------------------------------+ | @@datadir | +---------------------------------------------+ | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ | +---------------------------------------------+ 1 row in set (0.00 sec)Here is the snapshot where MySQL store database files i.e. the same path we got above −Now, let us verify whether ... Read More

## NavigableMap put() Method in Java

Updated on 30-Jul-2019 22:30:24

62 Views

The NavigableMap put() method is used to set a specific key and value in the NavigableMap.The following is an example to implement NavigableMap put() method −Example Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { NavigableMap n = new TreeMap(); n.put(5, "Tom"); n.put(9, "John"); n.put(14, "Jamie"); n.put(1, "Tim"); n.put(4, "Jackie"); n.put(15, "Kurt"); ... Read More

## Get Enumeration over HashSet in Java

Updated on 30-Jul-2019 22:30:24

150 Views

To get enumeration over HashSet, first declare the HashSet and add elements −HashSet hs = new HashSet(); hs.add("P"); hs.add("Q"); hs.add("R");To get enumeration −Enumeration e = Collections.enumeration(hs);The following is an example to get Enumeration over HashSet −Example Live Demoimport java.util.*; public class Demo {    public static void main(String[] args) {       HashSet hs = new HashSet();       hs.add("P");       hs.add("Q");       hs.add("R");       Enumeration e = Collections.enumeration(hs);       while (e.hasMoreElements())       System.out.println(e.nextElement()); } }OutputP Q R

## What was the Bubonic Plague all about?

Updated on 30-Jul-2019 22:30:24

56 Views

Bubonic Plague is a dreadful disease also called Black Death. This pandemic disease was spread during 1346 - 1353 which cost the lives of nearly 200 Million people in Europe. This Plague was mostly caused by the Oriental rat fleas that live on black rats which entered through merchant ships into Europe through the Mediterranean Sea. This Black death was estimated to have killed nearly 60% of the Europe population.Cause and IdentificationBubonic Plague is caused by the bacterium Yersinia Pestis which can cause several forms of Plague. This gets spread by the rats and may also result from the exposed ... Read More