- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4332 Articles for Java 8
64 Views
The set() method of the AbstractList class is used to replace the element at the specified position in this list with the specified element. It returns the element that gets replaced.The syntax is as follows:public E set(int index, E ele)Here, the parameter index is the index of the element to replace, whereas ele is the element to be stored at the specified position.To work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to implement set() method of the AbstractlList class in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractList; public class Demo { public static void main(String[] ... Read More
132 Views
The get() method of the AbstractList class is used to get the element at the specified position in the list. It returns the element at the position set as parameter.The syntax is as follows:public abstract E get(int index)Here, index is the index of the element to return.To work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to implement get() method of the AbstractlList class in Java:Exampleimport java.util.LinkedList; import java.util.AbstractList; public class Demo { public static void main(String[] args) { AbstractList myList = new LinkedList(); myList.add(50); ... Read More
265 Views
To add elements to AbstractList class, the add() method is provided by the AbstractList class. The elemnt gets appended at the end of the list.The syntax is as follows:public boolean add(E ele)Here, the parameter ele is an element to be appended to this listTo work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to add elements to AbstractlList class in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractList; public class Demo { public static void main(String[] args) { AbstractList myList = new LinkedList(); myList.add(50); myList.add(100); ... Read More
517 Views
The AbstractList class provides an implementation of the List interface.For an unmodifiable listProgrammer needs to extend this class and provide implementations for the get(int) and size() methods.For a modifiable listProgrammer must override the set(int, E) method. If the list is variable-size the programmer must override the add(int, E) and remove(int) methods.The following is the syntax:public abstract class AbstractList extends AbstractCollection implements ListTo work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to implement AbstractList class:Example Live Demoimport java.util.LinkedList; import java.util.AbstractList; public class Demo { public static void main(String[] args) { AbstractList myList ... Read More
61 Views
The removeAll() is a method inherited from AbstractCollection class. It removes all the elements of this collection that are also contained in the specified collection.The syntax is as follows:public boolean removeAll(Collection c)Here, the parameter c is the collection having elements to be removed from this collection.To work with the AbstractSequentialList class in Java, you need to import the following package:import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList removeAll() method in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList absSequential = new LinkedList(); absSequential.add(210); ... Read More
60 Views
The containsAll() method of the AbstractSequentialList checks for all the elements in this collection. It returns TRUE if all this collection contains all the elements in the specified collection i.e. if the two collections are same.The syntax is as follows:public boolean containsAll(Collection c)Here, c is the collection to be checkedTo work with the AbstractSequentialList class in Java, you need to import the following package:import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList containsAll() method in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList absSequential = new LinkedList(); ... Read More
155 Views
The difference between toArray() and toArray(T[] arr) is that both the methods returns an array containing all of the elements in this collection, but the latter has some additional features i.e. the runtime type of the returned array is that of the specified array.The syntax is as follows:public T[] toArray(T[] arr)Here, arr is the array into which the elements of this collection are to be stored, To work with the AbstractSequentialList class in Java, you need to import the following package:import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList toArray() method in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class ... Read More
515 Views
You can add/set an auto increment constraint to a column in a table using the ALTER TABLE command.SyntaxALTER TABLE table_name ADD id INT PRIMARY KEY AUTO_INCREMENTAssume we have a table named Dispatches in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location with description as shown below:+--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | ProductName | varchar(255) | YES | UNI | NULL | | | CustomerName | varchar(255) | YES | ... Read More
255 Views
You can drop a constraint on a column of a table using the ALTER TABLE command.SyntaxALTER TABLE table_name DROP CONSTRAINT MyUniqueConstraint;Assume we have a table named Dispatches in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location with description as shown below:+--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | ProductName | varchar(255) | YES | UNI | NULL | | | CustomerName | varchar(255) | YES | | NULL | ... Read More
328 Views
You can add a not null constraint to a column of a table using the ALTER TABLE command.SyntaxALTER TABLE table_name MODIFY column_name datatype NOT NULL;Assume we have a table named Dispatches in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location with description as shown below:+--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | ProductName | varchar(255) | YES | | NULL | | | CustomerName | varchar(255) | YES | | NULL ... Read More