- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
3 ways to initialize an object in Java
Consider a class Tester which has implemented Cloneable interface. Now you can initialize an object using following three ways −
1. Using new keyword.
Tester tester1 = new Tester();
2. Using Class.forName() method
Tester tester4 = (Tester)Class.forName("Tester").newInstance();
3. Using clone method.
Tester tester2 = tester1.clone();
- Related Articles
- Different ways to create an object in java?
- How do we initialize an array within object parameters in java?
- How many ways are there to initialize a final variable in java?
- How to initialize an array in Java
- Initialize an ArrayList in Java
- How many ways to make an object eligible for GC in Java?
- Python - Ways to initialize list with alphabets
- How many ways are there to initialize the instance variables of a class in java?
- What are all the ways an object can be created in Java?
- How to initialize an array in JShell in Java 9?
- How to initialize an array using lambda expression in Java?
- Initialize an Array with Reflection Utilities in Java
- How to declare, create, initialize and access an array in Java?
- Different ways to traverse an Array in Java?
- Initialize HashSet in Java

Advertisements