![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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 9326 Articles for Object Oriented Programming
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
2K+ Views
The getName() method is used to get the names of the entities such as primitive type, interface, class, array class, void etc. that represented by the class objects. These names are returned in the form of a string.A program that gets the name of a primitive type using getName() method is given as follows -Example Live Demopublic class Demo { public static void main(String[] argv) throws Exception { String name1 = float.class.getName(); System.out.println(name1); String name2 = int.class.getName(); System.out.println(name2); String name3 = char.class.getName(); ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
152 Views
Elements can be filled in a byte array using the java.util.Arrays.fill() method. This method assigns the required byte value to the byte array in Java. The two parameters required are the array name and the value that is to be stored in the array elements.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Arrays; public class Demo { public static void main(String[] argv) throws Exception { byte[] byteArray = new byte[5]; byte byteValue = 5; Arrays.fill(byteArray, byteValue); System.out.println("The byte array content is: " + Arrays.toString(byteArray)); ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
366 Views
A new instance of an Array can be 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.A program that demonstrates the creation of an array using the Array.newInstance() method 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, 5); Array.set(arr, 0, 5); Array.set(arr, 1, 1); Array.set(arr, 2, 9); Array.set(arr, 3, 3); Array.set(arr, 4, 7); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
107 Views
An array can be initialized using the method java.util.Arrays.fill() that is a utility method provided in the java.util.Arrays class. This method assigns the required value to all the elements in the array or to all the elements in the specified range.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Arrays; public class Demo { public static void main(String[] arg) { int[] arr = {2, 5, 8, 1, 9}; System.out.print("The array elements are: "); for (int i = 0; i < arr.length; i++) { System.out.print(arr[i] ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
3K+ Views
The byte array in Java can be filled by using the method java.util.Arrays.fill(). This method assigns the required byte value to the byte array in Java. The two parameters required for java.util.Arrays.fill() are the array name and the value that is to be stored in the array elements.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Arrays; public class Demo { public static void main(String[] a) { byte arr[] = new byte[] {5, 1, 9, 2, 6}; System.out.print("Byte array elements are: "); for (int num : arr) { ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
454 Views
To compute the elapsed time of an operation in milliseconds in Java, we use the System.currentTimeMillis() method. The java.lang.System.currentTimeMillis() returns the current time in milliseconds.Declaration −The java.lang.System.currentTimeMillis() is declared as follows −public static long currentTimeMillis()The method returns time difference in milliseconds between the current time and midnight, January 1, 1970 (UTC or epoch time).Let us see a program to compute the elapsed time of an operation in milliseconds in Java −Example Live Demopublic class Example { public static void main(String[] args) throws Exception { // finding the time before the operation is executed long ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
99 Views
Two byte 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 byte 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 byte[] { 1, 7, 5 }, new byte[] { 1, 7, 5 }); System.out.println("The two byte arrays are ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
224 Views
A multi-dimensional array can be easily printed by using the method java.util.Arrays.deepToString() in Java. This method converts the multi-dimensional array to string and prints the array contents enclosed in square brackets.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 [][]= { {5, 8, 6, 3}, {1, 9, 7}, {4, 8, 2}, {6} }; System.out.println("The multi-dimensional array content is:"); System.out.println(Arrays.deepToString(arr)); } }OutputThe multi-dimensional array content is: [[5, 8, 6, 3], [1, 9, 7], [4, 8, ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
301 Views
An array can be sorted in case-sensitive order using the java.util.Arrays.sort() method. Only a single argument required in this case for this method i.e. the array to be sorted. 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[] arr = new String[] { "apple", "mango", "Banana", "Melon", "orange" }; System.out.print("The unsorted array is: "); System.out.println(Arrays.toString(arr)); Arrays.sort(arr); System.out.print("The sorted array in case-sensitive order is: "); System.out.println(Arrays.toString(arr)); } ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
242 Views
A byte array can be sorted using the java.util.Arrays.sort() method with a single argument required i.e. the array to be sorted. A program that demonstrates this is given as follows −Example Live Demoimport java.util.Arrays; public class Demo { public static void main(String[] args) { byte[] arr = new byte[] { 4, 1, 9, 7, 5}; System.out.print("The original byte array is: "); for (byte i: arr) { System.out.print(i + " "); } Arrays.sort(arr); System.out.print("The sorted byte array is: "); ... Read More