- 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
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
2K+ Views
One of the methods the Timer class is void scheduleAtFixedRate(TimerTask task, Date firstTime, long period). This method schedules the specified task for repeated fixed-rate execution, beginning at the specified time.In fixed-rate execution, each execution is scheduled with respect to the scheduled run time of the initial execution. Fixed-rate execution is apt for repetitive activities that are respond to absolute time. Likewise, fixed-rate execution is appropriate for scheduling multiple repeating timer tasks that must remain in sync.Declaration − The java.util.Time.scheduleAtFixedRate(TimerTask task, Date firstTime, long period) method is declared as follows −public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period)Here, task is the ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
4K+ Views
The java.util.Arrays.sort() method can be used to sort a subset of the array elements in Java. This method has three arguments i.e. the array to be sorted, the index of the first element of the subset (included in the sorted elements) and the index of the last element of the subset (excluded from the sorted elements). Also, the Arrays.sort() method does not return any value.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Arrays; public class Demo { public static void main(String[] args) { int arr[] = { 1, 9, 7, 3, 2, 8, ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
119 Views
Two long arrays can be compared in Java using the java.util.Arrays.equals() method. This method returns true if the arrays are equal and false otherwise. The two arrays are equal if they contain the same number of elements in the same order.A program that compares two long arrays using the Arrays.equals() method is given as follows −Example Live Demoimport java.util.Arrays; public class Demo { public static void main(String[] argv) throws Exception { boolean flag = Arrays.equals(new long[] { 450L, 150L, 375L }, new long[] { 450L, 150L, 375L }); System.out.println("The two long arrays are equal? ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
534 Views
An array can be converted into a fixed size list using the java.util.Arrays.asList() method. This method is basically a bridge between array based AP!’s and collection based API’s.A program that demonstrates the conversion of an array into a generic list is given as follows −Example Live Demoimport java.util.Arrays; import java.util.Collections; import java.util.List; public class Demo { public static void main(String[] args) { String str[] = new String[]{"apple", "orange", "mango", "guava", "melon"}; List list = Arrays.asList(str); System.out.println("The list is: " + list); } }The output of the above program is as ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
173 Views
An array is created using the java.lang.reflect.Array.newInstance() method. This method basically creates a new array with the required component type as well as length.The array is filled using the java.lang.reflect.Array.setInt() method. This method sets the required integer value at the index specified for the array.The array displayed using the for loop. A program that demonstrates this is given as follows −Example Live Demoimport java.lang.reflect.Array; public class Demo { public static void main (String args[]) { int arr[] = (int[])Array.newInstance(int.class, 10); int size = Array.getLength(arr); for (int i = 0; iRead More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
61 Views
The getDeclaringClass() method returns the Class object for the class in which the object was declared. This happens only if the Class of the Class object is a member of another class. Otherwise this method returns null.Also, if a primitive type, array class, void etc. are represented by the Class object, then the getDeclaringClass() method returns null.A program that demonstrates the getDeclaringClass() method is given as follows −Example Live Demopackage Test; import java.lang.reflect.*; public class Demo { public static void main(String[] args) { Method[] m = String.class.getMethods(); for(int i = 0; i < m.length; ... Read More
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
309 Views
The canonical name of a class can be obtained using the java.lang.Class.getCanonicalName() method. This method returns the canonical name of the underlying class and returns null if there is no canonical name for the underlying class.A program that demonstrates the getCanonicalName() method to obtain the canonical name is given as follows −Example Live Demopackage Test; import java.lang.*; public class Demo { public static void main(String[] args) { Demo obj = new Demo(); Class c = obj.getClass(); System.out.println("The canonical name of the underlying Class is: " + c.getCanonicalName()); } }OutputThe canonical ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
159 Views
The getName() method is used to get the names of the entities such as interface, class, array class, void etc. that are represented by the class objects. These names are returned in the form of a string. The getPackage() method gets the package for the given class.A program that gets the class name for various objects is given as follows −Example Live Demopackage Test; import java.io.IOException; import java.util.HashMap; public class Demo { public static void main(String args[]) throws IOException { Object obj = "string"; System.out.println("The class name is: " + obj.getClass().getName()); ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
2K+ Views
In order to get the component type of an Array Object in Java, we use the getComponentType() method. The getComponentType() method returns the Class denoting the component type of an array. If the class is not an array class this method returns null.Declaration − The java.lang.Class.getComponentType() method is declared as follows -public Class getComponentType()Let us see a program to the get the component type of an Array Object in Java -Example Live Demopublic class Example { public static void main(String[] args) { int[] array = new int[] {1, 2, 3}; // obtain the Class ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
85 Views
In order to fill an array in Java, we use the Array.setInt() method. The java.lang.reflect.Array.setInt(Object array, int index, int value) method assigns the value of the component with a particular index of the given array object to the specified integer value.Declaration − The java.lang.reflect.Array.setInt(Object array, int index, int value) is declared as follows -public static void setInt(Object array, int index, int value) throws IllegalArgumentException, ArrayIndexOutOfBoundsExceptionLet us see a program to fill an array in Java using the Array.setInt() method to fill an array in Java -Example Live Demoimport java.lang.reflect.Array; public class Example { public static void main(String[] args) { ... Read More