Title | Advancedjavanotes - Advanced Java brief notes |
---|---|
Author | Apex Mind |
Course | Advance Java |
Institution | Savitribai Phule Pune University |
Pages | 3 |
File Size | 35.1 KB |
File Type | |
Total Downloads | 99 |
Total Views | 203 |
Advanced Java brief notes...
How to create and destroy objects
1.1 Introduction
Java programming language, originated in Sun Microsystems and released back in 1995, is one of the most widely used pro-
gramming languages in the world, according to TIOBE Programming Community Index. Java is a generalpurpose programming
language. It is attractive to software developers primarily due to its powerful library and runtime, simple syntax, rich set of sup-
ported platforms (Write Once, Run Anywhere - WORA) and awesome community.
In this tutorial we are going to cover advanced Java concepts, assuming that our readers already have some basic knowledge of
the language. It is by no means a complete reference, rather a detailed guide to move your Java skills to the next level.
Along the course, there will be a lot of code snippets to look at. Where it makes sense, the same example will be presented using
Java 7 syntax as well as Java 8 one.
1.2 Instance Construction
Java is object-oriented language and as such the creation of new class instances (objects) is, probably, the most important concept
of it. Constructors are playing a central role in new class instance initialization and Java provides a couple of favors to define
them.
1.2.1 Implicit (Generated) Constructor
Java allows to define a class without any constructors but it does not mean the class will not have any. For example, let us
consider this class:
package com.javacodegeeks.advanced.construction;
public class NoConstructor {
}
This class has no constructor but Java compiler will generate one implicitly and the creation of new class instances will be
possible using new keyword.
final NoConstructor noConstructorInstance = new NoConstructor();
1.2.2 Constructors without Arguments
The constructor without arguments (or no-arg constructor) is the simplest way to do Java compiler’s job explicitly....