This post originated from an RSS feed registered with Java Buzz
by instanceof java.
Original Post: Simple Way to Import all Missing Packages at Once : Eclipse shortcut
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
1.How to import all missing packages at once in java program eclipse:
While writing a java program or copied some line to eclipse then we need to import corresponding java packages.
Instead of checking one by one there is a short cut in eclipse to import corresponding packages at once
There is a short cut key to import all missing packages at once
"CTL+SHIFT+O" then one popup will come with all corresponding packages so we need to select corresponding missing package name then it automatically come. one by one it will automatically ask and we need to select.
Lets see an example program.
1.Copy This program and paste in eclipse and remove all packages. 2.Then it will show some errors on classes 3. select CTL+SHIFT+O 4.Select missing packages
package com.javacheckvaluehashmap;
public class HashmapExample{
public static void main(String[] args) {
//create an Hashmap object
HashMap<String, String> hashmap = new HashMap();
//Add key values pairs to hashmap
hashmap.put("1","One");
hashmap.put("2","Two");
hashmap.put("3","Three");
hashmap.put("4","Four");
hashmap.put("5","Five");
hashmap.put("6","Six");
boolean isExists = hashmap.containsValue("Six");
System.out.println("The value Six exists in HashMap ? : " + isExists);