Java Programing laungage

java.util Projects

java.util Project 1

Using get method in preferences

In this page of the tutorials we are going to learn how to use the get() method. In preference Every value will be store in a particular node in one or two preference tree by the help of the preference API and has a String key value with it which must be unique within that particular node of the tree.

Previous Home Next
adplus-dvertising

There are seven kind of "get()" methods in the Preferences class, and every method for each of the valid preference types. Here we makes it easier to understand by the simple example. In this given example we explain a simple way for using the get method in preferences. Get() method is the most useful method with the help of that method we can stored data in the class and can also print the value of that stored value by using simple print command.

Example


package r4r;
import java.util.*;
import java.util.prefs.Preferences;
public class getmethodtest {
	
public static void main(String[] args) { Preferences pre = Preferences.userNodeForPackage(getmethodtest.class); String str = pre.get("First", "R4R"); String str1 = pre.get("Second", "Tech Soft"); System.out.println(str); System.out.println(str1); } }
Previous Home Next