- 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
New keyword in Java
Yes, it is similar to a new keyword of C++. a new keyword is used to initialize/create an object. See the following example −
Employee employee = new Employee();
Here new keyword is used to create an object of class Employee.
new Employee() invokes the constructor of the class Employee.
new keyword can also be used without assigning the object to a reference variable. See the example −
String name = new Employee().getName();
Here we are creating an object using new keyword and then invoked a method getName() on the object and passed the result to a variable.
- Related Articles
- Using the new keyword in C#
- Does static factory method internally use new keyword to create object in java?
- Creating a JavaScript array with new keyword.
- This keyword in Java
- super keyword in Java
- final keyword in Java
- instanceof Keyword in Java
- Private Keyword in Java
- Protected Keyword in Java
- Public Keyword in Java
- static Keyword in Java
- synchronized Keyword in Java
- transient Keyword in Java
- volatile Keyword in Java
- What is the 'new' keyword in JavaScript?

Advertisements