Advertisement
Properties prop = new Properties();
Advertisement
Methods | Description |
---|---|
int size() | Returns the total number of elements in Stack. |
boolean empty() | Returns true if Stack is empty, else false. |
String getProperty(String key) | Pushes the element on the top of Stack. |
Object setProperty(String key, String value) | Sets a new property in System. |
void list(PrintStream out) | Sends the list of properties to the output stream. |
import java.util.*;
class Properties1
{
public static void main(String... ar)
{
Properties prop= new Properties();
prop.setProperty("Football", "Pele");
prop.setProperty("Golf", "Tiger Woods");
prop.setProperty("Formula 1", "Michael Schumacher");
prop.setProperty("Basketball", "Michael Jordan");
prop.setProperty("Boxing", "Mohammad Ali");
System.out.println("Size of properties = "+ prop.size());
System.out.println("Value associated with Key, Golf = "+ prop.getProperty("Golf"));
//using list() method to send the list of properties on the output stream, "System.out"
prop.list(System.out);
}
}
Size of properties = 5
Value associated with Key, Golf = Tiger Woods
-- listing properties --
Boxing=Mohammad Ali
Football=Pele
Basketball=Michael Jordan
Golf=Tiger Woods
Formula 1=Michael Schumacher
Properties prop= System.getProperties();
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement