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
Post a Comment