There are following two ways to iterate through HashSet: 1) Using Iterator 2) Without using Iterator Example 1: Using Iterator import java.util.HashSet; import java.util.Iterator; class… [Read More]
Difference between String and StringBuffer
In this article, we will discuss the difference between String and StringBuffer. Both of these classes used to handle sequence of characters. However they are… [Read More]
Difference between StringBuilder and StringBuffer
In this article we are gonna discuss the differences between StringBuilder and StringBuffer. Before discussing the differences, lets have a look at what java documentation… [Read More]
Java StringBuffer substring()
In this tutorial, we will discuss the Java StringBuffer substring() method with the help of examples. The syntax of substring() method is: sb.substring(4) //substring starting… [Read More]
Java StringBuffer replace()
In this tutorial, we will discuss Java StringBuffer replace() method with the help of examples. Syntax of replace() method: //replace substring from index 4 to… [Read More]
StringBuilder append() null values as “null” String
While working with StringBuilder you may have come across a strange behaviour of append() method for null values. If you append a null value to… [Read More]
How to append a newline to StringBuilder
There are following two ways to append a new Line to a StringBuilder object:1) StringBuilder.append(“\n”);2) StringBuilder.append(System.getProperty(“line.separator”)); Example In this example we have a StringBuilder object… [Read More]
Java – Get Set view of Keys from HashMap
Description Program to get the Set of keys from HashMap. Example import java.util.Iterator; import java.util.HashMap; import java.util.Set; class HashMapExample{ public static void main(String args[]) {… [Read More]
How to check if a HashMap is empty or not?
Description Program to check if a HashMap is empty or not. We are using isEmpty() method of HashMap class to perform this check. Program import… [Read More]
Clone a HashMap in Java
Description A program to clone a HashMap. We will be using following method of HashMap class to perform cloning. public Object clone(): Returns a shallow… [Read More]
- « Previous Page
- 1
- …
- 36
- 37
- 38
- 39
- 40
- …
- 65
- Next Page »