Difference between revisions of "Java interview"

From Hawk Wiki
Jump to: navigation, search
(Created page with "==Basic== ===Generic === Similar with c++ template. <pre class="java"> * * Generic version of the Box class. * @param <T> the type of value being boxed: public class Box<...")
 
(No difference)

Latest revision as of 03:16, 4 April 2012

Basic

Generic

Similar with c++ template.

/**
 * Generic version of the Box class.
 * @param <T> the type of value being boxed
 */

public class Box<T> {

    // T stands for "Type"
    private T t;

    public void add(T t) {
        this.t = t;
    }

    public T get() {
        return t;
    }
}