- 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 4336 Articles for Java 8
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
3K+ Views
In order to compute minimum element of ArrayList with Java Collections, we use the Collections.min() method. The java.util.Collections.min() returns the minimum element of the given collection. All elements must be mutually comparable and implement the comparable interface. They shouldn’t throw a ClassCastException.Declaration −The Collections.min() method is declared as follows −public static T min(Collection c)where c is the collection object whose minimum is to be found.Let us see a program to find the minimum element of ArrayList with Java collections −Example Live Demoimport java.util.*; public class Example { public static void main (String[] args) { List list ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
8K+ Views
In order to copy elements of ArrayList to another ArrayList, we use the Collections.copy() method. It is used to copy all elements of a collection into another.Declaration −The java.util.Collections.copy() method is declared as follows −public static void copy(List
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
293 Views
In order to copy elements of ArrayList to Java Vector, we use the Collections.copy() method. It is used to copy all elements of a collection into another.Declaration −The java.util.Collections.copy() method is declared as follows −public static void copy(List
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
4K+ Views
In order to sort elements in an ArrayList in Java, we use the Collections.sort() method in Java. This method sorts the elements available in the particular list of the Collection class in ascending order.Declaration −The java.util.Collections.sort() method is declared as follows −public static void sort(List list)where list is an object on which sorting needs to be performed.Let us see a program to sort elements in an ArrayList in Java −Example Live Demoimport java.util.*; public class Example { public static void main (String[] args) { List zoo = new ArrayList(); zoo.add("Zebra"); zoo.add("Lion"); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
238 Views
An array can be easily printed by using the method java.util.Arrays.toString() in Java. This method returns a string representation of the array contents that is enclosed in square brackets. If the array is null, then this method returns null.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Arrays; public class Demo { public static void main(String args[]) { String str[] = {"John", "Harry", "Sally", "Emma", "Peter"}; System.out.println("The array content is:"); System.out.println(Arrays.toString(str)); } }OutputThe array content is: [John, Harry, Sally, Emma, Peter]Now let us understand the above program.The ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
2K+ Views
An array can be sorted in case-insensitive order using the java.util.Arrays.sort() method. Also the java.text.Collator class is required as Collator.getInstance() is used to obtain the Collator object for the required locale.A program that demonstrates this is given as follows −Example Live Demoimport java.text.Collator; import java.util.Arrays; public class Demo { public static void main(String args[]) { String[] arr = new String[] { "apple", "mango", "Banana", "Melon", "orange" }; System.out.print("The unsorted array is: "); System.out.println(Arrays.toString(arr)); Arrays.sort(arr, Collator.getInstance()); System.out.print("The sorted array in case-insensitive order is: "); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
3K+ Views
In order to get a synchronized list from an ArrayList, we use the synchronizedList(List ) method in Java. The Collections.synchronizedList(List ) method accepts the ArrayList as an argument and returns a thread safe list.Declaration −The Collections.synchronizedList(List ) method is declared as follows −public static List synchronizedList(List list)Let us see a program to get a synchronized List from ArrayList −Example import java.util.*; public class Example { public static void main (String[] args) { List list = new ArrayList(); list.add("Hello"); ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
991 Views
One of the methods in the Timer class is the void schedule(TimerTask task, long delay, long period) method. This method schedules tasks for repeated fixed-delay execution, beginning after the specified delay.In fixed-delay execution, each execution is scheduled with respect to the original execution time of the preceding execution. If an execution is delayed for a particular reason (case in point, garbage collection), the subsequent executions will be delayed as well.Declaration −The java.util.Timer.schedule(TimerTask task, long delay, long period) is declared as follows −public void schedule(TimerTask task, long delay, long period)Here, task is the task to be scheduled, delay is the delay ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
219 Views
Binary search on a double array can be implemented by using the methodjava.util.Arrays.binarySearch(). This method returns the index of the required double element if it is available in the array, otherwise it returns (-(insertion point) - 1) where the insertion point is the position at which the element would be inserted into the array.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Arrays; public class Demo { public static void main(String[] args) { double d_arr[] = { 5.2, 7.5, 9.7, 1.8, 4.0 }; Arrays.sort(d_arr); System.out.print("The sorted array is: ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
740 Views
To check if a given String contains only unicode letters, digits or space, we use the isLetterOrDigit() and charAt() methods with decision making statements.The isLetterOrDigit(char ch) method determines whether the specific character (Unicode ch) is either a letter or a digit. It returns a boolean value, either true or false.Declaration −The java.lang.Character.isLetter() method is declared as follows −public static boolean isLetter(char ch)The charAt() method returns a character value at a given index. It belongs to the String class in Java. The index must be between 0 to length()-1.Declaration −The java.lang.String.charAt() method is declared as follows −public char charAt(int index)Let us ... Read More