
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 33676 Articles for Programming

681 Views
You can sort an ArrayList using the sort() method of the Collections class this method accepts a list object as a parameter and sorts the contents of it in ascending order.Example:import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; public class ArrayListSample { public static void main(String[] args) { ArrayList list = new ArrayList(); list.add("JavaFx"); list.add("Java"); list.add("WebGL"); list.add("OpenCV"); Set set = new LinkedHashSet(list); Collections.sort(list); System.out.println(list); } }Output:[Java, JavaFx, OpenCV, WebGL]

266 Views
The synchronizedList(List list) method of the Collections class accepts a List object and returns a synchronized list backed by the specified list.Example:import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; public class ArrayListSample { public static void main(String[] args){ ArrayList list = new ArrayList(); list.add("JavaFx"); list.add("Java"); list.add("WebGL"); list.add("OpenCV"); Set set = new LinkedHashSet(list); Collections.synchronizedList(list); System.out.println(list); } }Output:[JavaFx, Java, WebGL, OpenCV]

6K+ Views
A regular expression is a group of characters that allows you to use a search pattern to find a string or a set of strings. RegEx is another name for regular expressions. The re module in Python is used to work with regular expressions. In this article, we learn how to extract non-digit characters in Python using regular expressions. We use \D+ regular expression in Python to get non-digit characters from a string. Where, \D returns a match that does not contain digits. + implies zero or more occurrences of characters. ... Read More

459 Views
The Collections class provides a method named reverse() this method accepts a list and reverses the order of elements in it.Example:import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; public class Sample { public static void main(String[] args){ ArrayList list = new ArrayList(); list.add("JavaFx"); list.add("Java"); list.add("WebGL"); list.add("OpenCV"); Set set = new LinkedHashSet(list); System.out.println(set); Collections.reverse(list); System.out.println(list); } }Output:[JavaFx, Java, WebGL, OpenCV] [OpenCV, WebGL, Java, JavaFx]

2K+ Views
There are two ways to match any one uppercase character in python using Regular Expression. One is the general method and other is using the regular expression. A regular expression is a series of characters that allows you to discover a string or a set of strings using a search pattern. Regular expressions are sometimes known as RegEx. In Python, the re module is used to work with regular expressions. How to Match an Uppercase Character? In this article we will match the uppercase vowel in Python using a regular expression. To do this we will use r'[A, E, I, ... Read More

1K+ Views
In this article, you will learn how to match any single lowercase vowel (a, e, i, o, u) using Python regular expressions (regex). We will understand how to use Python's re module to apply a pattern that finds these vowels in a string. Ways to Match Lowercase There are two ways to match any one lowercase vowel in Python using a Regular Expression. One is using the if loop, and the other is using a regular expression. Using the General Method ... Read More

94 Views
The removeLast() method of the java.util.LinkedList class removes and returns the last element of this list.Example:import java.util.*; public class LinkedListDemo { public static void main(String[] args) { LinkedList list = new LinkedList(); list.add("Hello"); list.add(2); list.add("Chocolate"); list.add("10"); System.out.println("LinkedList:" + list); System.out.println("Last element:" + list.removeLast()); System.out.println("LinkedList:" + list); } }Output:LinkedList:[Hello, 2, Chocolate, 10] Last element:10 LinkedList:[Hello, 2, Chocolate]

138 Views
The removeFirst() method of the java.util.LinkedList class removes and returns the first element from this list.Example:import java.util.*; public class LinkedListDemo { public static void main(String[] args) { LinkedList list = new LinkedList(); list.add("Hello"); list.add(2); list.add("Chocolate"); list.add("10"); System.out.println("LinkedList:" + list); System.out.println("First element:" + list.removeFirst()); System.out.println("LinkedList:" + list); } }Output:LinkedList:[Hello, 2, Chocolate, 10] First element:Hello LinkedList:[2, Chocolate, 10]

130 Views
The getLast() method of the class java.util.LinkedList returns the last element in this list.Example:import java.util.*; public class LinkedListDemo { public static void main(String[] args) { LinkedList list = new LinkedList(); list.add("Hello"); list.add(2); list.add("Chocolate"); list.add("10"); System.out.println("LinkedList:" + list); System.out.println("Last Element :" + list.getLast()); } }Output:LinkedList:[Hello, 2, Chocolate, 10] Last Element :10

169 Views
The getFirst() method of the class java.util.LinkedList returns the first element of the current list. Example Live Demo import java.util.*; public class LinkedListDemo { public static void main(String[] args) { LinkedList list = new LinkedList(); list.add("Hello"); list.add(2); list.add("Chocolate"); list.add("10"); System.out.println("LinkedList:" + list); System.out.println("First Element :" + list.getFirst()); } } Output LinkedList:[Hello, 2, Chocolate, 10] First Element :Hello