Results 1 to 1 of 1

Thread: Generic Classes

  1. #1
    marciojc is offline Member
    Join Date
    Dec 2010
    Rep Power

    Default Generic Classes

    hi folks,
    i have a problem with a generic class.

    Java Code:
    abstract class Label<B extends Comparable<B>> implements Comparable<Label<B>>,Semiring<Label<B>>{
    	private B value;
    	 * Label constructor.
    	 * Sets the value of Label <tt>value</tt>.
    	 *  @param value
    	public Label(B value){
    		this.value = value;
    	 * Returns the value of Label <tt>value</tt>.
    	 * @return <tt> B </tt> , the label value
    	public B getValue(){
    		return value;
    anda i have 5 instance of Label, for Integer, Double, ...
    Because the operations define in Semiring are diferent for each type.

    Java Code:
    public class LabelInteger extends Label<Integer>{
    	public LabelInteger(){
    	public LabelInteger(Integer value){
    Other class that i have is

    when i make a new Label, i do

    Java Code:
     Label<Integer> label1 want = new LabelInteger(1);
    i want to do

    Java Code:
     Label<Integer> label1 = new Label<Integer>(1);
    any suggestion??
    Last edited by marciojc; 12-18-2010 at 01:11 AM.

Similar Threads

  1. generic in arraylist
    By katturv in forum New To Java
    Replies: 4
    Last Post: 10-02-2010, 10:33 PM
  2. generic code
    By mac in forum New To Java
    Replies: 4
    Last Post: 05-27-2010, 06:06 PM
  3. The Generic Trend
    By this.that in forum Advanced Java
    Replies: 9
    Last Post: 02-26-2009, 02:46 AM
  4. A generic interface example
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 08:42 PM
  5. Generic Hashtables
    By ShoeNinja in forum New To Java
    Replies: 0
    Last Post: 12-04-2007, 11:43 PM

Posting Permissions

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