- 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 9313 Articles for Object Oriented Programming
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
912 Views
Synchronized ArrayList and CopyOnWriteArrayList are useful for synchronizing the ArrayList. This is necessary for a multi-threaded environment to make sure thread safety is achieved.The differences between Synchronized ArrayList and CopyOnWriteArrayList are given as follows −Synchronized ArrayListCopyOnWriteArrayListSynchronized ArrayList is used to synchronize the ArrayList.CopyOnWriteArrayList is used to synchronize the ArrayList.The Java 1.2 version first introduced the Synchronized ArrayList.The Java 1.5 version first introduced the CopyOnWriteArrayList.The Synchronized ArrayList should be used when there are more write operations than reading operations in ArrayList.The CopyOnWriteArrayList should be used when there are more read operations than write operations in ArrayList.This iterator is a fail-fast iterator.This ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
716 Views
A custom ArrayList can have multiple types of data and its attributes in general are based on the user requirements.A program that demonstrates a custom ArrayList is given as follows −Example Live Demoimport java.util.ArrayList; public class CustomArrayList { int n = 5; class Employee { int eno; String name; Employee(int eno, String name) { this.eno = eno; this.name = name; } } public static void main(String args[]) { int eno[] = {101, 102, 103, ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
67 Views
The Java Collection Framework contains the AbstractSequentialList class. This class is used to create and implement an unmodifiable list. Also this class implements the Collection interface and the AbstractCollection class.A program that demonstrates this is given as follows −Example Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { AbstractSequentialList list = new LinkedList(); list.add("John"); list.add("Martha"); list.add("Sally"); list.add("Susan"); list.add("Harry"); System.out.println("The elements are: " + list); } }The output of the above program is as follows ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
333 Views
The method java.io.InputStream.read() is used to read the next byte of data from the input stream. This method requires no parameters and it returns the next data byte in the form of int. If the stream end is reached, it returns -1.A program that demonstrates this is given as follows −Exampleimport java.io.InputStream; public class Demo { public static void main(String[] args) throws Exception { InputStream input = null; int i; char c; try { input = new FileInputStream("C://JavaProgram//data.txt"); System.out.println("The ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
324 Views
The method java.io.InputStream.mark() is used to mark the current position in this input stream. This method requires a single parameter i.e. the bytes that can be read before the position marked is invalidated.A program that demonstrates this is given as follows −Exampleimport java.io.FileInputStream; import java.io.InputStream; public class Demo { public static void main(String[] args) throws Exception { InputStream i = null; try { i = new FileInputStream("C://JavaProgram//data.txt"); System.out.println("Char : "+(char)i.read()); System.out.println("Char : "+(char)i.read()); System.out.println("Char : "+(char)i.read()); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
137 Views
The method java.io.InputStream.close() is used to close this input stream and release any system resources associated with the stream. This method requires no parameters and returns no value. Also, the IOException is thrown when an I/O error occurs.A program that demonstrates this is given as follows −Example Live Demoimport java.io.FileInputStream; import java.io.InputStream; public class Demo { public static void main(String[] args) throws Exception { InputStream i = null; int num = 0; try { i = new FileInputStream("C://JavaProgram//data.txt"); num = i.available(); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
A temporary file in the specified directory can be created using the method java.io.File.createTempFile(). This method requires three parameters i.e. the prefix to define the file name, the suffix to define the file extension and the directory in which the temporary file is to be created. It also returns the abstract path name for the temporary file created.A program that demonstrates this is given as follows −Exampleimport java.io.File; public class Demo { public static void main(String[] args) throws Exception { File directory = new File("C:/JavaProgram"); File file = File.createTempFile("temp", ".java", directory); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
862 Views
A temporary file with the specified extension suffix can be created using the method java.io.File.createTempFile(). This method requires two parameters i.e. the prefix to define the file name and the suffix to define the file extension. It also returns the abstract path name for the temporary file created.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo { public static void main(String[] args) throws Exception { File file = File.createTempFile("temp", ".java"); System.out.println(file.getAbsolutePath()); file.deleteOnExit(); } }The output of the above program is as follows ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
6K+ Views
A temporary file can be created using the method java.io.File.createTempFile(). This method requires two parameters i.e. the prefix to define the file name and the suffix to define the file extension. It also returns the abstract path name for the temporary file created.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo { public static void main(String[] args) throws Exception { File file = File.createTempFile("temp", null); System.out.println(file.getAbsolutePath()); file.deleteOnExit(); } }The output of the above program is as follows −OutputC:\Users\amit_\AppData\Local\Temp\temp6072597842246154962.tmpNow let us understand the above ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
6K+ Views
The method java.lang.System.getProperty() is used to obtain the system property. This system property is specified by the key which is the parameter for the method. To obtain the current working directory, the key used is user.dir.A program that demonstrates this is given as follows −Example Live Demopublic class Demo { public static void main(String[] argv) throws Exception { String currentDirectory = System.getProperty("user.dir"); System.out.println("The current working directory is " + currentDirectory); } }The output of the above program is as follows −OutputThe current working directory is c:\JavaProgramNow let us understand the above program.The current ... Read More