Here is example of linked hash map and custom example.
package Practice;
import java.security.KeyStore;
import java.util.*;
public class LinkedHashMapExample {
public static void main(String[] args)
{
LinkedHashMap l=new LinkedHashMap();
l.put(null,null);
l.put(null,null);//it takes only one null key
l.put(1,"ravi");
l.put(2,"kumar");
l.put(3,"sagar");
l.put(4,"Om");
l.remove(4);
System.out.print(l);
System.out.println(l.get(2));
l.clear();
System.out.println(l.values());
System.out.println(l.keySet());
Map map =new LinkedHashMap();
Home home=new Home("Ravi",23,25000,"Delhi");
Home home1=new Home("Ritu",24,21000,"Goa");
Home home2=new Home("Om",28,22000,"Mumbai");
Home home3=new Home("Sweta",28,24000,"Chennai");
map.put(1,home);
map.put(2,home1);
map.put(3,home2);
map.put(4,home3);
System.out.println(map.get(4));
}
}
class Home{
public String name;
int age;
public String address;
int income;
public Home(String name, int age,int income,String address){
this.name=name;
this.age=age;
this.income=income;
this.address=address;
}
}
Sorting and Searching Programs
Start with your Choice
-Important
Programs for Freshers
- Palindrome Number
- Prime
Number
- Swapping
Number
- Leap Year
- Odd and
Even Number
- Fibonacci
Series
- Armstrong
Number
- Factorial
Number
- Print
Table
Learn Pattern Programs
- Alphabet
pattern program in java
- Star
Pattern Programs in Java
- Square
pattern programs in java
- Diamond
Star pattern programs in java
- Number
Pattern Programs in java
- Diagonal
pattern program in java
Click to learn Array Programs
- 4 ways to
print Array in Java
- 2-D Array
in Java
- Anonymous
Array in Java
- Single
Dimensional Array in Java
- Find
Second Largest Number in Array
- Delete an
Element in Array in Java
- Common
Element in Array in Java
- Missing
Element in Array
- Insert
Element in Array
- Reverse
Array in Java
- Merge
Two Array in Java
- Smallest
and Largest Elements in Array
- Find Odd
and Even Number in Array
Click to Learn MySQL
Learn with us | HTML | CSS | JS | Bootstrap | JAVA | ADV JAVA |
MySQL | GIT
No comments:
Post a Comment