Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Understanding properties collection order

    I am sorry. You can see there are a lot of threads started by me. I am not spamming. Whatever threads I am starting are my genuine doubts. Thanks for your help.

    I am trying to understand the order in which the properties collection is printed.

    Output:
    Property Elements :{two=Pakistan, one=INDIA, three=USA, four=USA}

    JavaCollection.java
    Java Code:
    package com.tutorialspoint;
    import java.util.*;
    
    public class JavaCollection {
       Properties addressProp;
    
       // a setter method to set Property
       public void setAddressProp(Properties addressProp) {
          this.addressProp = addressProp;
       }
       // prints and returns all the elements of the Property.
       public Properties getAddressProp() {
          System.out.println("Property Elements :"  + addressProp);
          return addressProp;
       }
    }
    MainApp.java
    Java Code:
    package com.tutorialspoint;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class MainApp {
       public static void main(String[] args) {
          ApplicationContext context = 
                 new ClassPathXmlApplicationContext("Beans.xml");
    
          JavaCollection jc=(JavaCollection)context.getBean("javaCollection");
    
          jc.getAddressProp();
       }
    }
    Beans.xml
    Java Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    
       <!-- Definition for javaCollection -->
       <bean id="javaCollection" class="com.tutorialspoint.JavaCollection">
    
         <!-- results in a setAddressProp(java.util.Properties) call -->
         <property name="addressProp">
            <props>
               <prop key="one">INDIA</prop>
               <prop key="two">Pakistan</prop>
               <prop key="three">USA</prop>
               <prop key="four">USA</prop>
            </props>
          </property>
    
       </bean>
    
    </beans>

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,277
    Rep Power
    6

    Default Re: Understanding properties collection order

    Aha but at what point do you stop "spamming" in a forum and do you start looking for a proper book to study so you can start to minimize the need to ask others to tell you how to do stuff? Something to think about.

    It might just be that there is no order at all.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default Re: Understanding properties collection order

    What is wrong with the way it has printed?
    Have you looked at the API for Properties to see what it says in that regard?
    Or dug deeper into the class(es) is extends?

    This is all answerable from the API.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,277
    Rep Power
    6

    Default Re: Understanding properties collection order

    Well good luck with that, your learning process will be incredibly slow because of all the misinformation and gaps you'll have to deal with.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default Re: Understanding properties collection order

    The API is not a book.
    It is the single most important resource for Java development (hell, development in any language, IMO).

    Those tutorials there are clearly not helping you understand, though.
    And you would really help yourself (and those in the forums) if you at least attempted to come up with an answer to some of your questions and present that.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 8
    Last Post: 11-23-2012, 05:39 PM
  2. Need some understanding and help!
    By Kevinius in forum New To Java
    Replies: 8
    Last Post: 05-14-2011, 06:50 AM
  3. Understanding this recursion
    By Yakg in forum New To Java
    Replies: 6
    Last Post: 01-05-2011, 10:39 PM
  4. need help in understanding collection
    By ShinTec in forum Advanced Java
    Replies: 2
    Last Post: 04-24-2010, 03:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •