Mahesh Parahar has Published 255 Articles

How do I insert all elements from one list into another in Java?

Mahesh Parahar

Mahesh Parahar

Updated on 09-May-2022 09:00:35

4K+ Views

SolutionWe can add all elements of one list into another list easily using its addAll() method.Syntaxboolean addAll(Collection

How do I empty a list in Java?

Mahesh Parahar

Mahesh Parahar

Updated on 09-May-2022 08:57:11

660 Views

SolutionWe can clear a list easily using its clear() method.Syntaxvoid clear()Removes all the elements of the list.ThrowsUnsupportedOperationException − If the clear operation is not supported by this listExampleThe following example shows how to clear elements from the list using the clear() method.package com.tutorialspoint; import java.util.ArrayList; import java.util.List; public class ... Read More

How do I add an element to an array list in Java?

Mahesh Parahar

Mahesh Parahar

Updated on 09-May-2022 08:51:37

632 Views

SolutionWe can add element to an array list easily using its add() method.Syntaxboolean add(E e)Appends the specified element to the end of this list.Type ParameterE  − The runtime type of the element to be added.Parameterse  − Element to be appended to this listReturnsIt returns true.ThrowsUnsupportedOperationException  − If the add operation ... Read More

Adobe Photoshop - Photo & Design Software

Mahesh Parahar

Mahesh Parahar

Updated on 14-Feb-2022 12:00:07

1K+ Views

Adobe Photoshop is the most popular photo editor and designing software. Adobe Photoshop is available for Windows, macOS and iPAD. Adobe Photoshop is very easy to use and provides many useful features required for image editing and designing. Adobe Photoshop is an industry standard in photo editing and digital art. ... Read More

Difference between :focus and :active selector in HTML

Mahesh Parahar

Mahesh Parahar

Updated on 21-Dec-2021 07:28:36

584 Views

:focus:focus selector is used to applying a required style when a form element got to focus like button, link, input box. An element can get focus using mouse or using tab key. A focus remains on the element until another element gets focus.:active:active selector is used to indicating that an ... Read More

Difference between Tree Set and Hash Set in Java

Mahesh Parahar

Mahesh Parahar

Updated on 24-Apr-2021 18:44:19

14K+ Views

Hash set and tree set both belong to the collection framework. HashSet is the implementation of the Set interface whereas Tree set implements sorted set. Tree set is backed by TreeMap while HashSet is backed by a hashmap.Sr. No.KeyHash SetTree Set1Implementation Hash set is implemented using HashTable The tree set is implemented ... Read More

Difference between Comparable and Comparator in Java

Mahesh Parahar

Mahesh Parahar

Updated on 08-Jul-2020 07:25:33

3K+ Views

Comparable and comparator both are an interface that can be used to sort the elements of the collection. Comparator interface belongs to java.util package while comparable belongs to java.lang package. Comparator interface sort collection using two objects provided to it, whereas comparable interface compares" this" refers to the one objects ... Read More

Difference between sums of odd position and even position nodes of a Binary Tree in Java

Mahesh Parahar

Mahesh Parahar

Updated on 16-May-2020 14:54:17

140 Views

Problem StatementWith a given binary tree, write a program to find the difference between sum of nodes at odd position and even position. Assume root at level 0, odd position, left/right child of root at level 2, left child at odd position and right child at even position and so ... Read More

Difference between sums of odd level and even level nodes of a Binary Tree in Java

Mahesh Parahar

Mahesh Parahar

Updated on 16-May-2020 14:50:36

314 Views

Problem StatementWith a given binary tree, write a program to find the difference between sum of nodes at odd level and even level. Assume root at level 1, left/right child of root at level 2 and so on.Example        5       /   \     ... Read More

Difference between sums of odd and even digits.

Mahesh Parahar

Mahesh Parahar

Updated on 16-May-2020 14:49:21

384 Views

Problem StatementWith a given long integer n, write a program to find the difference between sum of the odd digits and even digits to be 0 or not. Index starts from 0.Examplen = 1212112 Sum of odd position elements = 2 + 2 + 1 = 5 Sum of ... Read More

Previous 1 ... 6 7 8 9 10 ... 26 Next
Advertisements