Featured
-
How to split a String
Below I have written a code to split a string.
by shahbaz.ahmmod -
Send Push Notification with Custom Data to iPhone device from Java Server Side
This blog will help you to send Push Notifications
by babita.dhami -
Tomcat and Eclipse Integration Error : “Unknown version of Tomcat was specified”
If you are adding Server in Eclipse for Tomcat, an
by chandan.ahluwalia -
Spring MVC and MongoDB
Repository Class Using MongoDB : Spring has th
by sumit.vyas -
How to create DLL file from java?
Hello Guy's This Blog will guide how to create D
by bhagwan.khichar
Tags
Scala
Scala is a programming language and full form is Scalable language. It first released in 2003.
Scala is object-oriented and functional language. Many companies that depend on Java switching to Scala to enhance their development productivity, s...
replaceAll() to replace square brackets in a String
To replace any character from a String, we generally use replaceAll() method of String.
Below is the example
String Str = new String("Hello + world +");
System.out.print("Output Value :" );
System.out.println(Str.replaceAl...
Remove duplicate items from ArrayList.
I am removing duplication from arraylist. To do this, first add all the items of arraylist to a HashSet.
HashSet takes only unique items.
Finally, take HashSet items to the arraylist.
List arrayList = new ArrayList<>();
arrayList.a...
Find Number of days between two given dates
Here, I am writing simple method to find out the number of days between two dates.
In many situations, we need to calculate it. So just pass two dates as parameters of the method and get the number of days in long data type.
publ...
Difference between ArrayList and Vector
Hi,
It is one of the important topics in java.
For dynamically resizable array we use ArrayList. ArrayList provides us fast access as compare to simple
array.
1. As we go to synchronization, Vector is synchronized means at a single time o...
Difference between HashSet and TreeSet
Hi,
I am explaining the difference between HashSet and TreeSet in Java.
First of all they both come from the same family. They implement the Set Interface.
In HashSet, values store in random order. That means it is not sure that the ele...
Add any character to String on a particular location
Sometimes, we need to change some special character on String to fulfill our requirements.
For example, we need to show phone number, i.e, 2001256443 as (200)-125-6443
Now we use the substring method of String to solve it.
We just add Stri...
Remove some particular character from a String
Sometime, we need to remove or replace some particular character from a String.
Below is the method by which we can accomplish this. I am using replaceAll() method of the String.
replaceAll() have two parameter as an arguments. First one is t...
How to reset ArrayList in Java - Clear vs RemoveAll
To reset ArrayList we have two options, one is to use clear() method and another is to use removeAll().
We dont need to worry if size of the ArrayList is small i.e. 10 to 100.
But if ArrayList size becomes huge the difference in the performan...
Convert Map to List
Map and List are the two commonly used data structures
Here I am writing way to convert Map to List.
Basically Map holds two things are key and value on the other hand list holds only values.
Both Map and List allow duplicate data.
Below i...
Convert String to Date in Java
Its very easy in java to convert String to Date.
Java provides SimpleDateFormat to handle Date related functionality.
Here we call parse() method of SimpleDateFormat.
Example
import java.text.SimpleDateFormat;
import java.util.Date;...
Get Current Date in Java
Hello,
We need current date in many situations.
Here I am writing different ways to get current date in java.
1. Get current date using java.util.Date.
Date currentDate = Date();
System.out.println(Current date : +currentDate);
O/P:
Curr...
Sorting using Collection
To sort the collection elements Collection class gives us the methods. In case of Set collection, we have
TreeSet that can use to set the Set elements.
We can sort elements of type String objects, Wrapper class objects and User-defined class...
Covariant Return Type
When return type of the method of super class is different than the return type of method of subclass and it
is also a method overriding then it is known as covariant return type.
And here the return type is non primitive.
I am writing the si...
Stack in java
In stack, we save elements in last-in, first-out manner. Stack extends the Vector class and have only one constructor that is default. By this default constructor, we can create an empty stack.
Below is the example.
public class Exampl...
SortedSet in Java
I am writing a way to implement SortedSet in java.
SortedSet have the properties of Set interface plus feature of sorting in ascending order. It is by default provides elements in ascending order. It is very useful in such situation when we do...
LinkedList implementation in Java
Hi friends,
Here I am writing a way to implement basic LinkedList.
First of all LinkedList has the properties of List interface and
AbstractSequentialList class because it implements List interface and extends
AbstractSequentialList.
...
How to initialize blank final variable
Blank final variables are those variables that are final but havent initialized at the time of declaration.
So its not possible to initialize it anywhere. Here is the solution.
We can initialize blank final variable only in the constructo...
Comparator Interface in java
Hi,
Here I am writing a simple way to use Comparator interface.
We use Comparator interface to order the objects.
First of all we need to import java.util package.
It have two methods :
Compare(Object o1, Object o2)
equals(Ob...
Static in Java
One of the most important topic that we encounter in java.
We can use static with class name, methods name, variables name and block.
Static keyword mainly used for memory management.
Static variable
Static variable takes memory o...