By default TreeMap elements are sorted in ascending order of keys. We can iterate the TreeMap in reverse order to display the elements in descending… [Read More]
Archives for 2014
How to sort a TreeMap by value in java
A TreeMap is always sorted based on its keys, however if you want to sort it based on its values then you can build a… [Read More]
Java program for binary to decimal conversion
There are two following ways to convert binary number to decimal number: 1) Using Integer.parseInt() method of Integer class.2) Do conversion by writing your own… [Read More]
Java Program for Decimal to Hexadecimal Conversion
There are two following ways to convert a decimal number to hexadecimal number: 1) Using toHexString() method of Integer class.2) Do conversion by writing your… [Read More]
Java Program for Decimal to Octal Conversion
In this guide, we will discuss the following two ways to convert decimal to octal in Java. Using predefined method toOctalString(int num) of Integer class… [Read More]
TreeMap Iterator example – Java
In this example we are iterating a TreeMap using Iterator and Map.Entry. import java.util.TreeMap; import java.util.Set; import java.util.Map; import java.util.Iterator; public class TreeMapExample { public… [Read More]
Remove all mappings from TreeMap example – Java
This is how to remove all the key-value mappings from TreeMap and make it empty. We are using clear() method of TreeMap class to perform… [Read More]
Remove Key-value mapping from TreeMap example
In this tutorial we are gonna see how to remove a Key-value mapping from TreeMap. We are using remove(Object key) method of TreeMap class to… [Read More]
Super keyword in java with example
The super keyword refers to the objects of immediate parent class. Before learning super keyword you must have the knowledge of inheritance in Java so… [Read More]
Final Keyword In Java – Final variable, Method and Class
In this tutorial we will learn the usage of final keyword. The final keyword can be used for variables, methods and classes. We will cover… [Read More]
Java program for bubble sort in Ascending & descending order
In this tutorial we are gonna see how to do sorting in ascending & descending order using Bubble sort algorithm. Bubble sort program for sorting… [Read More]
Java program to convert decimal to binary
There are three following ways to convert Decimal number to binary number: 1) Using toBinaryString() method of Integer class. 2) Do conversion by writing your… [Read More]
Java program to get IP address
In this example we are gonna see how to get IP address of a System. The steps are as follows: 1) Get the local host… [Read More]
Java Program to get input from user
In this tutorial we are gonna see how to accept input from user. We are using Scanner class to get the input. In the below… [Read More]
Difference between List and Set in Java
List and Set both are interfaces. They both extends Collection interface. In this post we are discussing the differences between List and Set interfaces in… [Read More]
- « Previous Page
- 1
- …
- 3
- 4
- 5
- 6
- 7
- …
- 16
- Next Page »