0

I couldn't find how to do this anywhere else online, though I'm sure it's really easy to do. I'm primarily self taught though, and I'd like to start learning to document my code properly. This "yellow box" that pops up in eclipse with information about the method - I want it to pop up on a custom object. For my example below I have a custom class called "System Properties" and a method called "getOs" but when I hover that option, no information comes up. How do I add information to my object?

This picture shows the yellow box enter image description here

This picture shows the lack of a "yellow box" on my object enter image description here

and then finally my custom objects code...

public class SystemProperties {

    private String os;

    public SystemProperties() {
        this.os = setOs();
    }

    private String setOs() {
        String osName = System.getProperty("os.name");
        if(osName.toLowerCase().contains("window"))
            return "Windows";
        else if(osName.toLowerCase().contains("mac"))
            return "Mac";
        else
            return "Linux";

    }

    /**
     * Method to grab the OS the user is running from
     * @return String - the os
     */
    public String getOs() {
        return this.os;
    }

}

Thank you in advance for your time and knowledge. :)

EDIT: When I import the project of the custom object, it works just fine. It only doesn't work when I export the project of the custom class to a jar file and then use that instead. Do I have to click an option on the export screen?

1 Answers1

1

Eclipse take the info from the notes above the methods in the built in objects.

see this:

    /**
 * Returns <tt>true</tt> if this map contains a mapping for the specified
 * key.  More formally, returns <tt>true</tt> if and only if
 * this map contains a mapping for a key <tt>k</tt> such that
 * <tt>(key==null ? k==null : key.equals(k))</tt>.  (There can be
 * at most one such mapping.)
 *
 * @param key key whose presence in this map is to be tested
 * @return <tt>true</tt> if this map contains a mapping for the specified
 *         key
 * @throws ClassCastException if the key is of an inappropriate type for
 *         this map
 * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
 * @throws NullPointerException if the specified key is null and this map
 *         does not permit null keys
 * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
 */
 boolean containsKey(Object key);

You can do the same to the methods of your own objects.

isaace
  • 3,336
  • 1
  • 9
  • 22