Home » Java programming language

Java Properties stringPropertyNames() Method with Example

Properties Class stringPropertyNames() method: Here, we are going to learn about the stringPropertyNames() method of Properties Class with its syntax and example.
Submitted by Preeti Jain, on March 21, 2020

Properties Class stringPropertyNames() method

  • stringPropertyNames() method is available in java.util package.
  • stringPropertyNames() method is used to get all the key exists in this Property list and here the key and its desired value are string along with unique key exists in the default property list to be viewed in a Set.
  • stringPropertyNames() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
  • stringPropertyNames() method does not throw an exception at the time of returning property names.


    public Set stringPropertyNames();


  • It does not accept any parameter.

Return value:

The return type of the method is Set, it returns set of keys exist in this property list along with the key exists in the default list.


// Java program to demonstrate the example 
// of Set stringPropertyNames()
// method of Properties

import java.util.*;

public class StringPropertyNamesOfProperties {
 public static void main(String arg[]) throws Exception {
  // Instantiate Properties object
  Properties prop = new Properties();

  prop.put("10", "C");
  prop.put("20", "C++");
  prop.put("30", "JAVA");
  prop.put("40", "PHP");
  prop.put("50", "SFDC");

  // Get all the properties of
  // this object in a set
  Set set = prop.stringPropertyNames();

  // Display Set View
  System.out.println("prop.stringPropertyNames(): " + set);


prop.stringPropertyNames(): [50, 40, 30, 20, 10]


Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.