Pulling values from a Java Properties file in order?

Extend java.util.Properties, override both put() and keys(): import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Properties; import java.util.HashMap; public class LinkedProperties extends Properties { private final HashSet<Object> keys = new LinkedHashSet<Object>(); public LinkedProperties() { } public Iterable<Object> orderedKeys() { return Collections.list(keys()); } public Enumeration<Object> keys() { return Collections.<Object>enumeration(keys); } public Object put(Object key, Object … Read more

Getter property with arguments

To answer the question: No, it is not possible, and as already pointed out, a getter with a parameter would look just like a method. The thing you are thinking about might be an indexed default property, which looks like this: class Test { public string this[int index] { get { return index.ToString(); } } … Read more

Should I use “public” attributes or “public” properties in Python?

Typically, Python code strives to adhere to the Uniform Access Principle. Specifically, the accepted approach is: Expose your instance variables directly, allowing, for instance, foo.x = 0, not foo.set_x(0) If you need to wrap the accesses inside methods, for whatever reason, use @property, which preserves the access semantics. That is, foo.x = 0 now invokes … Read more