Basically there are three way to convert an primitive value to string so that if we have requirement to use that primitive as a string then we can you this concept and way of conversion but now the point is out of these three way which one is the best and take less time and doesn't have any performance issue.
The three ways of converting primitive into string are :
1. Using Empty string
2. Using valueOf() with String class
3. Using toString()...

String is a reference data type and hence string literals are treated as object and get stored in the string constant pool. We must have to define any string within double-quote otherwise it will give compilation error. String can be represented in two form either with using ' new ' operator or without using new operator.
Two way of string representation in java :
1....
It is the manually implemented coding for doing cloning. This concept has came to overcome the limitation found with shallow cloning which fails to clone the data member. Through deep cloning we can be able to cover up the problem with the shallow cloning. Now with the help of deep cloning we can able to clone the object members as well but to achieve this we don't have any predefined method, so we need to write our own code. Deep Cloning is just...

It is a default cloning in java implemented by the Java vendor simply by using one predefined method in the Object class i.e clone(). Using shallow cloning we can only be able to clone the member of the class but fails to clone object members of the class. To clone the object member we need to write our own code which is also called as Deep Cloning.
To achieve...
Cloning is a concept used to create a new object of the existing object. It means creating another object in the memory same as the existing one by copying the content of it.
For cloning a object java vendor has provided a method i.e clone() method in the Object class which is used to clone the object.
Clone() method is defined as protected in the Object and return the Object class object. Signature of the clone() is :-
protected Object...
It is a concept in java to achieve the Dynamic / Run-time polymorphism. It is the process of assigning sub-class object in super type reference later if needed that sub-class object can be type-caste into its super type. Dynamic dispatch can be achieved only with the instance member.
Important point regarding dynamic dispatch
1. If we are trying to access instance member with dynamic dispatch concept then it will access sub-class overridden...
Interface is a keyword in java and also a concept in java to over come the limitation of not supporting multiple inheritance by java. Now with the concept of interface we can have implement multiple interface full filing the concept of a " single class extending more than one class ". In the case of class we can extend only one but with the interface we can implement more than one interface.
Click here to know why java is not supporting multiple...
When we use an abstract modifier before the name of any user-define class then it is called as an abstract class. Abstract class in java has only method signature whose implementation must be in its sub-classes.
Important points regrading Abstract class
1. It cannot be instantiate means we cannot create object of an abstract class.
2. An abstract class can have instance member.
3. Abstract class doesn't have any method implementation instead...
Abstract is a keyword in java. So its a reserved word in java. general meaning of abstract is to hide the implementation, only show the outer structure. Now in computer science its meaning is that user can have their own implementation with abstract method.
Where we can use abstract keyword ?
Abstract can be used with class and method.
By using abstract with the method a user can able to have their own implementation according to their wish....
Like public and private, protected is also a access modifier which has different visibility scope and it is also one of the keyword in java. Its scope are valid to the other packages but it should be within the sub-class. Like private we can be able to use protected scope with the constructor, methods, variables and inner classes. Accessing protected member outside its scope will give compilation error saying " Not Visible ".
Note : We cannot...
Private is the keyword in java and it is also called as the access modifier in java which defines the visibility to the members of the class like methods, constructors, variables etc. Declaring private to the members of the class will limit theirs visibility to that class only. If we are trying to access any private member in another class then compiler will give compilation error as " Member are not visible ".
Note : We cannot use...
As its name ' public ' itself indicates that any member of the class declared as public will be visible and accessible ANYWHERE. We have two scope in java programs :
1. Class scope
Sub-class in the same package --> Public is visible .
Sub-class in different package --> Public is visible.
Another class in the same package --> Public is visible.
Same class in the same package ...
Access Modifier in java defines the scope of accessibility of methods, constructors, variables etc. So to access the different members of the class/interfaces with different scope we have three access modifiers :
1. Public --> Defines visibility everywhere
2. Private --> Defines visibility within the current class only
3. Protected...
Like other classes in java , anonymous is also a type of class but it doesn't have any name like other classes have their own name either defined by the user or pre-defined in the java by the java vendors. So anonymous class is defined as the class without name and it is defined by the user only.
No need of wonder that how a class can exist without any name ?
Its not that it doesn't have any name but generated by the compiler at the run-time....
Local inner class is a class which is define local to the outer class. So it must be defined within the local scope of a class like method, constructor or initialization block . A class within a class in never treated as the local inner class. And most importantly scope of the inner class will be limited to where it is declared, outside of which it is not valid. As local inner class is the local scope to the outer class then we all know that within...
Like Instance inner class we have also static inner class. Static instance class is loaded at the time of loading the outer class as it is declared as static that means it will act as the static member of the outer class and hence we can be able to define static member as it get initialized at the time of loading the outer class.
Important point regarding Static inner class
1. We can be able to define static and instance both in the static inner...
As the name itself indicates that inner class with non-static scope that means a member of outer class which is of instance scope called as instance inner class. Instance inner class is itself a class but we cannot use any static member.
Why we cannot use any static member in instance inner class ?
--> It is first treated as the member of outer class. Because of this if it is declared as non-static that means JVM is not going to load the class...
Inner class in a class defined as a class inside another class. So it is itself a class but first it will act as a member of that class. As we know that we cannot make a class as static but inner class can be made as static which proves that it is first a member of a class in which it is defined . We can execute our class with its name but to execute a inner class we need to take help of outer class that proves that an inner class has identity...
Like this in java one more most important keyword is there i.e super. super in Java has a wide use and it is mainly used to call the super class constructor explicitly by the user and implicitly used by the JVM to initialize the super class property.
Have you ever wondered that how super class members get instantiated by creating subclass object ?
Let suppose we have two class A and B following inheritance relation where B is extending A that means...
this is one of the most important keyword in java which refers to the current class object. Like we are creating an object for our class similarly internally a object is there called as this which points to the current class object unless we create an Object.We can say that 'this ' is not an actual object but it points to the current class object. Accessibility of ' this ' refers to the current object that means if we have more than one object...
Subscribe to:
Posts (Atom)