Example Using put() method

In this example you will learn that how a put function is used in the program, in this example first time when it initialize it don't have any value but when we give some of the value in it by put() function then it will show the value what it have in its

Example Using put() method

In this example you will learn that how a put function is used in the program, in this example first time when it initialize it don't have any value but when we give some of the value in it by put() function then it will show the value what it have in its

Example Using put() method

Example Using put() method

     

 

In this example you will learn that how a put function is used in the program, in this example first time when it initialize it don't have any value but when we give some of the value in it by put() function then it will show the value what it have in its container.

 

Here is the Complete Code of the Example :

import java.util.prefs.Preferences;

public class put 
  {
  public static void main(String[] args
  {

 
  Preferences prefs = Preferences.userNodeForPackage(put.class);

 
  String x = prefs.get("one"" ");

  System.out.println(x);
  
  prefs.put("one""roseindia");

  }

 }

After thoroughly knowing the code you should save the file by "put.java" file name and when after compiling the code you run your program you will get the output given below .

Here is the Output of the Example :


C:\anshu>javac put.java

C:\anshu>java put
roseindia

Downoload this example.