Register Now

Login

Lost Password

Enter your email to reset your password.

BY Author

Java – Properties

Declaration

class Properties

Properties class extends the Hashtable class.

It maintains list that contains both key & value as a String.

List of Properties Constructors (CLICK HERE)

List of Properties Methods (CLICK HERE)

Example

 import java.util.Iterator;
 import java.util.Properties;
 import java.util.Set;

 public class PropertiesDemo 
 {
     public static void main(String args[]) 
     {
         Properties developer = new Properties();
		
         developer.put("C", "Dennis Ritchie");
         developer.put("C++", "Bjarne Stroustrup");
         developer.put("JAVA", "James Gosling");
         developer.put("PERL", "Larry Wall");
		
         Set languages = developer.keySet();    
         Iterator itr = languages.iterator();
         String s;
		
         while(itr.hasNext())
         {  
             s = (String) itr.next();
             System.out.println(s + " language was developed by " + 
            		                               developer.getProperty(s));
         }  
     }
 }

Output

PERL language was developed by Larry Wall
C++ language was developed by Bjarne Stroustrup
JAVA language was developed by James Gosling
C language was developed by Dennis Ritchie

 

Leave a reply