list - Implementing Java Interface with extra method in implementing Class -


first post gentle. :) i'm not sure doing wrong here, can me out.

i have class implements list interface. class has it's own method add item list if not in list. trouble when try use conditionaladd method, error stating can't find method because looking in workflowsubtype class. please see below:

when instantiate class using:

list<workflowsubtype> currentviolations = new violations(); 

this definition of class implements list interface:

import java.util.*;  public class violations<e> implements list<e>{  public violations() {}  public void conditionaladd(e violation){      if(violation != null)      if(!this.contains(violation))     add(violation); }  @override public <t> t[] toarray(t[] a) { return null; }  @override public boolean add(e e) { return false; }   @override.... 

so how come can't access conditionaladd method. currentviolations object created list, it's violations type. correct in saying this?

thanks in advance.
rw

you need cast instance violations. if don't so, compiler interprets list, , list not have conditionaladd method. this: ((violations<workflowsubtype>)currentviolations).conditionaladd(whatever);


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -