Java Articles

Page 341 of 450

What is Deserialization in Java?

Monica Mona
Monica Mona
Updated on 25-Feb-2020 365 Views

After a serialized object has been written into a file, it can be read from the file and Deserialized that is, the type information and bytes that represent the object and its data can be used to recreate the object in memory.Exampleimport java.io.*; public class DeserializeDemo { public static void main(String [] args) { Employee e = null; try { FileInputStream fileIn = new FileInputStream("/tmp/employee.ser"); ...

Read More

What is the difference between Serialization and Deserialization in Java?

Samual Sam
Samual Sam
Updated on 25-Feb-2020 2K+ Views

Serialization Java provides a mechanism, called object serialization where an object can be represented as a sequence of bytes that includes the object's data as well as information about the object's type and the types of data stored in the object.Exampleimport java.io.*; public class SerializeDemo { public static void main(String [] args) { Employee e = new Employee(); e.name = "Reyan Ali"; e.address = "Phokka Kuan, Ambehta Peer"; e.SSN = 11122333; ...

Read More

Which method must be implemented by all threads in Java?

Monica Mona
Monica Mona
Updated on 25-Feb-2020 1K+ Views

While creating a thread class we must override the run() method of the Thread class. This method provides an entry point for the thread and you will put your complete business logic inside this method.Exampleclass ThreadDemo extends Thread { private String threadName; ThreadDemo( String name) { threadName = name; System.out.println("Creating " + threadName ); } public void run() { System.out.println("Running " ...

Read More

Where and how can I create a private constructor in Java?

Swarali Sree
Swarali Sree
Updated on 25-Feb-2020 405 Views

We can use a private contractor in a Java while creating a singleton class. The Singleton's purpose is to control object creation, limiting the number of objects to only one. Since there is only one Singleton instance, any instance fields of a Singleton will occur only once per class, just like static fields. Singletons often control access to resources, such as database connections or sockets.ExampleThe easiest implementation consists of a private constructor and a field to hold its result, and a static accessor method with a name like getInstance().The private field can be assigned from within a static initializer block ...

Read More

What does the method ensureCapacity(int, minCapacity) do in java?

Govinda Sai
Govinda Sai
Updated on 25-Feb-2020 201 Views

The ensureCapacity(int minCapacity) method of the class java.util.ArrayList increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.Exampleimport java.util.ArrayList; public class ArrayListDemo { public static void main(String args[]) { ArrayList arrlist = new ArrayList(5); arrlist.add(10); arrlist.add(50); arrlist.add(30); arrlist.ensureCapacity(15); for (Integer number : arrlist) { System.out.println("Number = " + number); } } }OutputNumber = 10 Number = 50 Number = 30

Read More

What does the method contains(obj o) do in java?

Nikitha N
Nikitha N
Updated on 25-Feb-2020 172 Views

The contains(Object) method of the java.util.ArrayList class returns true if this list contains the specified element.Exampleimport java.util.ArrayList; public class ArrayListDemo { public static void main(String[] args) { ArrayList arrlist = new ArrayList

Read More

What is the Java Runtime Environment (JRE)?

Ayyan
Ayyan
Updated on 25-Feb-2020 665 Views

JRE is Java Runtime Environment and is the machine-specific implementation of JVM. It contains libraries like rt.jar, class loaders etc which are used by JVM.

Read More

What is the Java Runtime Environment (JRE)?

Ayyan
Ayyan
Updated on 25-Feb-2020 665 Views

JRE is Java Runtime Environment and is the machine-specific implementation of JVM. It contains libraries like rt.jar, class loaders etc which are used by JVM.

Read More

Initialization, declaration and assignment terms in Java

Arushi
Arushi
Updated on 25-Feb-2020 2K+ Views

A variable provides us with named storage that our programs can manipulate. Each variable in Java has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.You must declare all variables before they can be used. Following is the basic form of a variable declaration − data type variable [ = value][, variable [ = value] ...] ;Here data type is one of Java's datatypes and variable is the name of the variable. To ...

Read More

Best book to learn Java programming for beginners

Daniol Thomas
Daniol Thomas
Updated on 25-Feb-2020 316 Views

Following books are on top from popularity and content wise and are a good resource to learn java programming from beginner to advance level.

Read More
Showing 3401–3410 of 4,498 articles
« Prev 1 339 340 341 342 343 450 Next »
Advertisements