Java Programing laungage

java.util Projects

java.util Project 1

Retrieval Multiple Value by put and get method

In this page of the tutorials, we are going to find out the flow of using put and get method of the preferences. After reading, coding, and running we have the ability of using the get and put method.

Previous Home Next

Here we are using some extra package method like Arrays, Iterator. here we can watch that how we are putting the value of the preferences like int type ,Boolean type, and simple key value after that we are just using the get method we can access all the stored value of the preferences. As we recently completed all of the put and get type, we are try to described it more clearly.


package r4r;
import java.util.*;
import java.util.prefs.Preferences;
public class retrievedmultiplevalue {
public static void main(String[] args) throws Exception {
retrievedmultiplevalue rmv = new retrievedmultiplevalue();
public retrievedmultiplevalue() throws Exception{
Preferences pre = Preferences.userNodeForPackage(this.getClass());
pre.put("Country", "India");
pre.putInt("intValue", 2);
pre.putBoolean("booleanValue", false);
int usageCount = pre.getInt("intValue", 0);
pre.putInt("Count is", usageCount); Iterator itr = Arrays.asList(pre.keys()).iterator(); while (itr.hasNext()) { String key =; System.out.println(key + ": " + pre.get(key, null)); } } }
Previous Home Next