Add Element to Specified Index of ArrayList in Java

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

571 Views

An element can be added to the specified index of an ArrayList by using the java.util.ArrayList.add() method. This method has two parameters i.e. the specific index at which to insert the element in the ArrayList and the element itself. If there is an element already present at the index specified by ArrayList.add() then that element and all subsequent elements shift to the right by one.A program that demonstrates this is given as follows −Example Live Demoimport java.util.ArrayList; import java.util.List; public class Demo { public static void main(String args[]) throws Exception { List ... Read More

What is Polynomial Code?

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

4K+ Views

A polynomial code is a linear code having a set of valid code words that comprises of polynomials divisible by a shorter fixed polynomial is known as generator polynomial.They are used for error detection and correction during the transmission of data as well as storage of data.Types of Polynomial CodesThe types of polynomial codes are:Cyclic Redundancy CodeBose–Chaudhuri–Hocquenghem (BCH) CodesReed–Solomon CodesRepresentation of Bit Strings with PolynomialsThe code words, which are essentially bit strings, are represented by polynomials whose coefficients are either 0 or 1. A 𝑘 – bit word is represented by a polynomial ranging from 𝑥0 to 𝑥𝑘−1. The order ... Read More

Replace All NULL Values in a Specific Field of a Table in MySQL

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

334 Views

To replace all NULL values in a particular field of a particular table, use UPDATE command with IS NULL property. The syntax is as follows:UPDATE yourTableName SET yourColumnName=”yourValue’ WHERE yourColumnName IS NULL;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table Employee_Information_Table    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(20),    -> Salary int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command. The query to insert record is as ... Read More

Find Minimum Element of HashSet in Java

karthikeya Boyini
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

Different Shapes of Galaxies

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

810 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

Algorithm for Computing the CRC

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

7K+ 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

Select Not Null Column from Two Columns in MySQL

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

9K+ 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

Chandu yadav
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

Get Enumeration Over HashSet in Java

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

336 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

Earn from Learning a New Language

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

204 Views

Getting acquainted with local and foreign languages is opening the doors to plenty of opportunities. Languages like Hindi, Punjabi, Gujarati, Urdu, Tamil, Malayalam, Bengali and many other Indian languages as well as the foreign languages like French, German, Spanish, Arabic, Korean, Japanese, Chinese, Italian, Russian and Persian, etc. not only boost your chances of getting a job but also offer you an opportunity to get to know a completely diverse world with a unique viewpoint.Educational QualificationHowever, there is no educational qualification required to learn any language. You can choose any local or foreign language as a subject during your schooling. ... Read More

Advertisements