- 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 338 Articles for Java Programming
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
661 Views
The toArray() method of the java.util.The ArrayList class returns an array containing all of the elements in this list in proper sequence (from first to the last element). This acts as a bridge between array-based and collection-based APIs.ExampleLive Demoimport java.util.ArrayList; public class ArrayListDemo { public static void main(String[] args) { ArrayList arrlist = new ArrayList(5); arrlist.add(20); arrlist.add(40); arrlist.add(10); arrlist.add(15); arrlist.add(25); for (Integer number : arrlist) { System.out.println("Number = " + number); ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
126 Views
The fill(Object[] a, Object val) method of the java.util.Arrays class assigns the specified Object reference to each element of the specified array of Objects.Exampleimport java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { Object arr[] = new Object[] {10.5, 5.6, 4.7, 2.9, 9.7}; System.out.println("Actual values: "); for (Object value : arr) { System.out.println("Value = " + value); } Arrays.fill(arr, 12.2); System.out.println("New values after using fill() method: "); for (Object value : arr) { System.out.println("Value = " + value); } } }OutputActual values: Value = 10.5 Value = 5.6 Value = 4.7 Value = 2.9 Value = 9.7 New values after using fill() method: Value = 12.2 Value = 12.2 Value = 12.2 Value = 12.2 Value = 12.2
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
52 Views
The toString(int[]) method of the class java.util.Arrays return a string representation of the contents of the specified int array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space).Exampleimport java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { int[] i1 = new int[] { 33, 12, 98 }; System.out.println("The array is:"); for (int number : i1) { System.out.println("Number = " + number); ... Read More
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
222 Views
A multi-threaded program contains two or more parts that can run concurrently and each part can handle a different task at the same time making optimal use of the available resources specially when your computer has multiple CPUs.Multi-threading enables you to write in a way where multiple activities can proceed concurrently in the same program.Exampleclass RunnableDemo implements Runnable { private Thread t; private String threadName; RunnableDemo( String name) { threadName = name; System.out.println("Creating " + threadName); } public void run() { ... Read More
![Syed Javed](https://www.tutorialspoint.com/assets/profiles/13356/profile/60_64693-1512709676.jpg)
1K+ Views
The InputStream class in Java provides read() method. This method accepts a byte array and it reads the contents of the input stream to the given byte array.ExampleLive Demoimport java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; public class StreamToByteArray { public static void main(String args[]) throws IOException{ InputStream is = new BufferedInputStream(System.in); byte [] byteArray = new byte[1024]; System.out.println("Enter some data"); is.read(byteArray); String s = new String(byteArray); System.out.println("Contents of the byte stream are :: "+ s); ... Read More
![Monica Mona](https://www.tutorialspoint.com/assets/profiles/13520/profile/60_87298-1512650151.jpg)
2K+ Views
In Java, a multi-dimensional array is nothing but an array of arrays.2D array − A two-dimensional array in Java is represented as an array of one-dimensional arrays of the same type. Mostly, it is used to represent a table of values with rows and columns −Int[][] myArray = {{10, 20, 30}, {11, 21, 31}, {12, 22, 32} }In short, a two-dimensional array contains one-dimensional arrays of elements. It is represented by two indices where the first index denotes the position of the array and the second index represents the position of the element within that particular array − Example ... Read More
![Syed Javed](https://www.tutorialspoint.com/assets/profiles/13356/profile/60_64693-1512709676.jpg)
5K+ Views
The Character class of the java.lang package wraps a value of the primitive datatype char. It offers a number of useful class (i.e., static) methods for manipulating characters. You can create a Character object with the Character constructor. Character ch = new Character('a'); Following are the notable methods of the Character class. 1 isLetter() Determines whether the specified char value is a letter. 2 isDigit() Determines whether the specified char value is a digit. 3 isWhitespace() Determines whether the specified char value is white space. 4 isUpperCase() Determines ... Read More