Problem with comparable generics

Hi all,
I just started using generics and I cannot solve the following issue:
Here's the code snippet that gives me all the trouble:
public class BinaryLogicalExpression{
  private Comparable leftOperand;
  private Comparable rightOperand;
  public Boolean evaluate(){
    if(leftOperand.compareTo(rightOperand)<0)
    { return true; }
    else{ return false; }
} It gives an "unchecked" warning. Trying to suppress the warning, I did the following:
public class BinaryLogicalExpression<T>{
  private Comparable<T> leftOperand;
  private Comparable<T> rightOperand;
  public Boolean evaluate(){
    if(leftOperand.compareTo(rightOperand)<0)
    { return true; }
    else{ return false; }
  }which is obviously wrong because rightOperand should be of type T and not Comparable<T>. Apart from that, I am running out of ideas...

Try starting withpublic class BinaryLogicalExpression<T extends Comparable<T>>{
  private T leftOperand;
  private T rightOperand;

Similar Messages

  • Gnerics problem with Comparator

    i have to creat a program which deals with LinkedList...but I'll creat my own list which its name is "InOrderLinkedList"
    it's function is to take numbers and put them in the right order node
    i made 2 codes but one of them has an error (which i think it's about Generic Comparator Problem)
    and the other code doesn't have any error...but doesn't do any thing when i run it
    first code is:_
    import java.util.Collections;
    import java.util.List;
    import java.util.*;
    import java.util.Iterator;
    import java.util.ListIterator;
    import java.lang.Integer;
    import java.lang.Object;
    import java.lang.*;
    import javax.swing.*;
    class Node<E>{
              E item_;
              Node nextNode_=null;
              public void setItem(E item){
                   item_=(E)item;
              public Node<E> getNextNode(){
                   return nextNode_;
              public void setNextNode(Node nextNode){
                   this.nextNode_=nextNode;
              public String toString(){
                   return item_.toString();
              E getItem(){
                   return (E)item_;
    /*interface Comparator<E>{
         public int compareTo(E e1,E e2);
    class Comp implements Comparator <Integer>{
         public int compare(Integer e1,Integer e2){
         return e1-e2;
    class LinkedListme<E>{
         Node<Integer> head;
         Node<Integer> tail;
         int size=0;
         public void addFirst(int e){
              /*Node<E> node= new Node<E> (e);
              node.setNextNode(head);
              head=node;
              size++;*/
         public void addLast(int e){
              /*Node<E> node=new Node<E> (e);
              if(head==null){
                   head=node;
                   size++;
                   return;*
              Node<E> lastNode=head;
              while(lastNode.getNextNode()!=null){
                   lastNode=lastNode.getNextNode();
              lastNode.setNextNode(node);*/
         public void clear(){
              head=null;
              size=0;
         public int removeFirst(){
              Node<Integer> firstNode=head;
              head= head.getNextNode();
              size--;
              return firstNode.getItem();
         public int removeLast(){
              if (size==1)
                   return removeFirst();
              if (size==0)
                   return 0;
              Node<Integer> secondLast=head;
              Node<Integer> lastNode=null;
              while(secondLast.getNextNode().getNextNode()!=null){
                   secondLast=secondLast.getNextNode();
              lastNode=secondLast.getNextNode();
              secondLast.setNextNode(null);
              size--;
              return lastNode.getItem();
         public int remove(int index){
              Node<Integer> beforeRemoved=head;
              Node<Integer> removed=null;
              for(int i=1;i<(index-1);i++){
                   beforeRemoved=beforeRemoved.getNextNode();
              removed=beforeRemoved.getNextNode();
              beforeRemoved.setNextNode(removed.getNextNode());
              return removed.getItem();
         public void add(int index,int x){
              /*Node<E> beforeAdd=head;
              Node<E> newNode=new Node<E> (x);
              for(int i=1;i<(index-1);i++){
                   beforeAdd=beforeAdd.getNextNode();
              newNode.setNextNode(beforeAdd.getNextNode());
              beforeAdd.setNextNode(newNode);*/
         /*public void prnt(LinkedListme<E> l){
              System.out.print(l);
    public class InOrderLinkedList <E> extends LinkedListme<E>{
         public void add (int elem){
              Node <Integer> newNode = new Node <Integer>();
              newNode.setItem(elem);
              if(head==null){
                   head=newNode;
                   tail=newNode;
                   newNode.setNextNode(head);
                   head=newNode;
    //public class LinkedListme {
    public static void main(String[]args){
         InOrderLinkedList <Integer> list=new InOrderLinkedList <Integer>();
         Comp com=new Comp();
         list.add(5);
         list.add(5);
         list.add(3);
         list.add(6);
         list.add(3);
         list.add(2);
         list.add(1);
         Collections.sort(list,com); ///here is the error
         System.out.println(list.toString());
    the second code is:_
    import java.util.*;
    import java.util.Iterator;
    import java.util.ListIterator;
    import java.lang.Integer;
    import java.lang.*;
    import javax.swing.*;
    class Node<E>{
              E item_;
              Node <E>nextNode_=null;
              public void setItem(E item){
                   item_=(E)item;
              public Node<E> getNextNode(){
                   return nextNode_;
              public void setNextNode(Node <E>nextNode){
                   this.nextNode_=nextNode;
              public String toString(){
                   return item_.toString();
              E getItem(){
                   return (E)item_;
    /*interface Comparator<E>{
         public int compareTo(E e1,E e2);
    class Comp implements Comparator <Integer>{
         public int compare(Integer e1,Integer e2){
         return e1-e2;
    class LinkedListme<E>{
         Node<Integer> head;
         Node<Integer> tail;
         int size=0;
         public void addFirst(int e){
              /*Node<E> node= new Node<E> (e);
              node.setNextNode(head);
              head=node;
              size++;*/
         public void addLast(int e){
              /*Node<E> node=new Node<E> (e);
              if(head==null){
                   head=node;
                   size++;
                   return;*
              Node<E> lastNode=head;
              while(lastNode.getNextNode()!=null){
                   lastNode=lastNode.getNextNode();
              lastNode.setNextNode(node);*/
         public void clear(){
              head=null;
              size=0;
         public int removeFirst(){
              Node<Integer> firstNode=head;
              head= head.getNextNode();
              size--;
              return firstNode.getItem();
         public int removeLast(){
              if (size==1)
                   return removeFirst();
              if (size==0)
                   return 0;
              Node<Integer> secondLast=head;
              Node<Integer> lastNode=null;
              while(secondLast.getNextNode().getNextNode()!=null){
                   secondLast=secondLast.getNextNode();
              lastNode=secondLast.getNextNode();
              secondLast.setNextNode(null);
              size--;
              return lastNode.getItem();
         public int remove(int index){
              Node<Integer> beforeRemoved=head;
              Node<Integer> removed=null;
              for(int i=1;i<(index-1);i++){
                   beforeRemoved=beforeRemoved.getNextNode();
              removed=beforeRemoved.getNextNode();
              beforeRemoved.setNextNode(removed.getNextNode());
              return removed.getItem();
         public void add(int index,int x){
              /*Node<E> beforeAdd=head;
              Node<E> newNode=new Node<E> (x);
              for(int i=1;i<(index-1);i++){
                   beforeAdd=beforeAdd.getNextNode();
              newNode.setNextNode(beforeAdd.getNextNode());
              beforeAdd.setNextNode(newNode);*/
         /*public void prnt(LinkedListme<E> l){
              System.out.print(l);
    public class InOrderLinkedList <E> extends LinkedListme<E>{
         Comp com=new Comp();
         public void add (int elem){
              Node <Integer> newNode = new Node <Integer>();
              newNode.setItem(elem);
              if(head==null){
                   head=newNode;
                   tail=newNode;
              if(com.compare(head.getItem(), elem)>=0){
                   newNode.setNextNode(head);
                   head=newNode;
                   return;
                   Node<Integer> lastNode=head;
                   //Integer lastNodeInt=(Integer)lastNode;
              int compVal=com.compare(lastNode.getItem(), elem);
              while(compVal<0 && lastNode.getNextNode()!=null){
                   lastNode=lastNode.getNextNode();
              if(lastNode.getNextNode()==null){
                   lastNode.setNextNode(newNode);
              tail=newNode;     
              else{
                   newNode.setNextNode(lastNode.getNextNode());
                   lastNode.setNextNode(newNode);
    //public class LinkedListme {
    public static void main(String[]args){
         InOrderLinkedList <Integer> list=new InOrderLinkedList <Integer>();
         list.add(5);
         list.add(9);
         list.add(3);
         list.add(6);
         list.add(3);
         list.add(2);
         list.add(1);
         System.out.println(list.toString());
    what are thier problems??
    thanks

    So what's the error message?

  • Problem with comparing (excel related)

    Problem: Basically all the vi does is grab values from excel and compare it with a pre-determined value and if the returned value is greater than or equal the vi stops and returns the cell which gave it thar value. I think it may that I am telling excel to compare a string value to a decimal value but I have tried that and it seems to stop instantly with a value which is cleary wrong.
    I have attached the vi and  sample excel file which it searchs through
    Solved!
    Go to Solution.
    Attachments:
    ReturnLeftPeak test.vi ‏35 KB
    Importmacro1.xls ‏158 KB

    Don't see a problem. Start at A4 and it stops on the first iteration as it should (because the cell is blank it converts to a 0 which is greater than -30). Starting at A5 it steps down to A368, again just as it should.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Problem with Comparator

    I am trying to sort a class Merchant which has a MerchantKey .I need to sort merchant based on terminalId attribute in the MerchantKey class.
    My code looks like thispublic static Comparator BaseTerminalIDComparator = new Comparator() {
                             public int compare(Object merchant, Object anotherMerchant) {
                             String merchant1 = ((Merchant) merchant).getBaseTerminalId().trim();     
                             String merchant2 = ((Merchant) anotherMerchant).getBaseTerminalId().trim();     
                             return merchant1.compareTo(merchant2);     
    public String getBaseTerminalId() {
              return merchantKey.getBaseTerminalId();
         }     I am using this as below where ar is a ArrayList of Merchants.
    Collections.sort(ar, Merchant.BaseTerminalIDComparator);My problem is the sorting is not working as expected.Although a simialr attribute of the MerchantKey class works fine.
    Could some help me solve this ? Thanks.

    Please excuse the late entry - I had the exact same problem, except I was already comparing my string-converted-to-integer numerically, and it seemed that the comparator was not being "honored" in the order the Collections.sort used. Debugging output in the compare method indicated the sort was calling the comparator correctly, and that the comparator was returning the correct -1, 0, and +1 values - YET the sort still sorted in string order vs. the embedded int I am trying to sort on with the comparator. Without showing code, does this sound familiar? Not asking for help, just experience.

  • Acrobat 8 Mac have problem with comparing 2 documents!!!

    Hi All,
    Please help me out of some problem acrobat 8 pro.
    I am using Mac pro
    Mac OS X : Version 10.4.11
    2 x 2.66 GHz Dual-Core Intel Xeon Processor
    Memory : 6 GB
    Problem: When I am comparing 2 documents with having same canvas size, the speed of tilting is not that much fast comparing acrobat 7. Is there any settings do I need to keep extra to get faster like older version?
    Can somebody help about this starge problem....
    KInd Regards
    Janes

    There is nothing you can do to change the time it takes Acrobat to compare two different documents. The good news is that Acrobat 7 will frequently work on a computer that also has Acrobat 8 on it. What is the difference of speed between the two versions on the same document? You can download an Acrobat 9 trial to see if Acrobat 9 is faster.

  • Problem with functioning Generic Delta

    Hi Expert !
    I Have Created a Generic Delta and has Scheduled the Delta Load By Means of Process Chain In BI Side.
    Although it is showing Green(OK) status for the respected Request at PSA(saying No Data Exists FOR PSA) and ODS Lavel but no data is loaded at ODS.
    although the data for the same crieria is available in R/3 side.
    please share your idea what is reason behind........
    Regards
    Prakash

    Hii I have created Generic Delta On Function Module, also i had checked in RSA3 and it is showing data. Also I have checked the Function Module and the field on which i had created Delta, the Delta Parameters is coming.
    I am not able to find what actually the problem is........
    Please share your idea if you have any.
    Regards
    Prakash

  • Problem with Comparing Dates in MS Access

    Hai Friends
    I am using MS ACCESS 2000 Database
    I am using the following sqlString in AWT Frame class to fetch the date from MS ACcess Database
    I heard that while comparing with >= or <= we need to include # symbol between the date.
    I was tried by using #. But i am not able to get the results.
    please see the sql query and give me the solution.
    Thanksinadvance
    Yours
    Rajesh
    if(Enddate.getText().trim().equals(""))
    sqlString = "select * from data_comm_err where log_date >= '" + Startdate.getText() + "'";
    if(Startdate.getText().trim().equals(""))
    sqlString = "select * from data_comm_err where log_date <= '" + Enddate.getText() + "'";
    }

    non-proprietary query(portable):
    PreparedStatement ps = con.prepareStatement("select * from data_comm_err where log_date <= ? ");
    ps.setDate(1,new java.sql.Date(Startdate.getTime()));
    ResultSet r  = ps.executeQuery();
    ....note: for clarity and good programming style, don't capitalize the first letter of a variable(Startdate)
    Jamie

  • Problem with comparing different tables in huge database

    Hi!
    I'm experiencing a problem where I want to find out which records in one table (shoppingcart) does not exist in another table (shoppingcart_items).
    SHOPPINGCART
    ID-----------------CUSTOMER
    1------------------Adam
    2------------------Tor
    3------------------Alexis
    4------------------Fred
    SHOPPINGCART_ITEM
    ID----------------ITEM
    1-----------------Corn
    1-----------------Wheat
    3-----------------Syrup
    4-----------------Corn
    4-----------------Flakes
    No, I want to select all the records in SHOPPINGCART which do not have any occurans in SHOPPINGCART_ITEMS.
    I do this using the following statement:
    SELECT * FROM SHOPPINGCART WHERE ID NOT IN(
    SELECT ID FROM SHOPPINGCART_ITEM);
    Giving the following table:
    SHOPPINGCART
    ID-----------------CUSTOMER
    2------------------Tor
    The problem is that since I have a huge database, this takes to long. So, is there any smart way to do the same thing but much more efficient?
    Thanks!
    /Björn

    Did you try outer joins ? Example :
    TEST@db102 > select empno, ename from emp order by ename;
         EMPNO ENAME
          7876 ADAMS
          7499 ALLEN
          7698 BLAKE
          7782 CLARK
          7902 FORD
          7900 JAMES
          7566 JONES
          7839 KING
          7654 MARTIN
          7934 MILLER
          7788 SCOTT
          7369 SMITH
          7844 TURNER
          7521 WARD
    14 rows selected.
    TEST@db102 > select empno,ename from emp1 order by ename;
         EMPNO ENAME
          7876 ADAMS
          7499 ALLEN
          7698 BLAKE
          7902 FORD
          7839 KING
          7654 MARTIN
          7934 MILLER
          7788 SCOTT
          7369 SMITH
          7844 TURNER
          7521 WARD
    11 rows selected.
    TEST@db102 > select a.empno, a.ename from emp a, emp1 b
      2  where a.empno = b.empno(+)
      3  and b.empno is null
      4  order by a.ename;
         EMPNO ENAME
          7782 CLARK
          7900 JAMES
          7566 JONES
    TEST@db102 >

  • Problem with configuring generic database connectivity

    Hi All.
    I’m very new to Oracle. I’m trying to configure ODBC for excel to read data from excel into oracle table; however I cannot go thru. I followed some instructions from this forum and managed to configure the ODBC, updated listner.ora, tnsnames.ora and inithsodbc.ora files and successfully created a database link. However, when I tried the command SELECT * FROM TABLE$@EXCEL, I got the following message: ‘ORA-12154: TNS: could not resolve service name’. Is there any one to assist me to resolve the problem?
    Regards,
    Jasson Yotham
    [email protected]

    Is this the example you're looking for:
    http://technology.amis.nl/blog/?p=1303

  • Problem with comparing text item with hidden item

    Hi all,
    I have two items, one text field which has a user name and other item which is hidden which also has a username input from a file.
    I want to compare these two items.
    But when both items are text fileds am able to compare, but when one is made hidden unable to compare.
    Please help on this......
    thanks,
    Srini

    Hi Srini,
    As long as you understand that the user can change the value of ANY field, even it is hidden, then I would suggest something like:
    1 - Hide your existing Login button. On the button definition, in "Button Display Attributes" add the following into the Attributes setting:
    style="display:none"2 - In the Login region's Region Footer, create a new button:
    &lt;input type="button" class="t12Button" value="Login" onclick="javascript:checkNames();"&gt;(Note that I have used a class name of "t12Button" - change this to match your current theme)
    3 - Underneath that, add in your javascript:
    &lt;script type="text/javascript"&gt;
    function checkNames()
    if ($v('field1name') == $v('field2name'))
      doSubmit('loginbuttonname');
    &lt;/script&gt;Then, when the user clicks the new Login button, this triggers your javascript. This checks that the values for field1name and field2name match. If they do, if fires the normal submit for the page (the same as if you clicked the original Login button)
    Andy

  • Comparable problem with eclipse

    I want to use "Comparable" in eclipse, but always has a problem with a steatment that " The type Comparable is not generic; it cannot be parameterized with arguments <Node>".
    program is here:
    public class Node implements Comparable<Node>
         public int value;
         public boolean LeftchildSent; //used for checking if leftchild sent the value to the node at last round
         public boolean RightchildSent; //...
         public boolean ParentSent; //...
         //constructor
         public Node(int value, boolean LeftchildSent, boolean RightchildSent, boolean ParentSent, Node left, Node right)
              this.value = value;
              this.LeftchildSent = false;
              this.RightchildSent = false;
              this.ParentSent = false;
         //implements comparable
         public int ComparableTo(Node n)
              if(value < n.value) return -1;
              if(value == n.value) return 0;
              if(value > n.value) return 1;
    }anybody help, thanks very much

    Be sure to:
    1- Use a JRE System Library 5.0+ for your project.
    (Properties / Java Build Path / Libraries)
    2- Use a compiler compliance level 5.0+ for your project.
    (Properties / Java Compiler / Compiler Compliance Level)
    3- Change your last method to:    public int compareTo(Node n) // *** bad name used
            if(value < n.value) return -1;
            if(value > n.value) return 1;
            return 0; // *** be sure to have a return statement
        }or better:     public int compareTo(Node n)
            return value - n.value;
        }

  • Problem with reflection in Generics

    I'm using the Prototype compiler for JSR-014 and I am having a big problem with reflection. In the simplest case
    class n<T> {
        void go() {
         this.getGenericType().getTypeParameters();
         this.getClass().getGenericInterfaces();
    }I get a "cannot resolve symbol" on both lines. A glance at the jar included with the prototype shows why: all the collection classes are there, and a lot of the java.lang types, but not java.lang.Class and none of the java.lang.reflection classes.
    So what gives? Is reflection not supported yet? (gaak!) Is there another jar I am supposed to download?
    Thanks

    Schapel is right.
    but also
    The signatures for fields and methods will include the generic types.
    If you really wanted to, this would work.
    get the Class's ClassLoader,
    work out the name of the Class's file, and get an inputStream to this resource (from the classloader). (This bit works because I use as a diagnostics tool to see if classes are loaded from my jar, or my patches directory - see below).
    Write some stuff to read the class file and parse out the generic signatures for the things you are interested in.
    I don't think this last part would fit into anyones definition of "fun", however the specs are all available, and it may turn out simpler than at first appearances.
    Here's the code I use to get the location of where a class is loaded from.
        static URL getLoadPath(Class theClass) {
            StringBuffer resourcename = new StringBuffer(theClass.getName());
            for(int i=0;i < resourcename.length(); i++) {
                if(resourcename.charAt(i) == '.') {
                    resourcename.setCharAt(i,'/');
            resourcename.append(".class");
            return theClass.getClassLoader().getResource(resourcename.toString());
        }if you use getResourceAsStream() in place of getResource() you will have the .class file as an inputStream which you can read and parse.
    Have Fun
    Bruce

  • Problem with generics in general framework

    Hi,
    I've just started using generics and I've been able to solve most of my problems with type declarations etc, but I still have a few problems left.
    My current problem is in a class which has a map of classes which implements a generic typed interface (The interface is called Persister in the code below).
    The map is declared as:
    private Map<Class<?>, Persister<?>> persisters =
              new HashMap<Class<?>, Persister<?>>(); And the interface is declared as:
    interface Persister<T>My problem is that a method in the class which has the map should return a Collection of type T.
    Can that be done without supressing warnings?
    It's probably hard to understand what I mean (since I don't know the terminology) so here's a complete minimal example which illlustrates the problem. The problem is in the selectAll method in the DbFacade class.
    The lines:
         Persister persister = persisters.get(clazz);
         Collection<E> result = persister.selectAll(clazz);Needs to be altered but to what? (Or do I need to make more changes?)
    Thanks in advance
    Kaj
    ///////////////// Start of complete example
    import java.util.*;
    class ClientSample {
         public static void main(String[] args) {
              DbFacade facade = new DbFacade();
              //Works..
              Collection<Holiday> holidays = facade.selectAll(Holiday.class);
    class DbFacade {
         //Map with many different type of persisters,
         //one persister per class.
         private Map<Class<?>, Persister<?>> persisters =
              new HashMap<Class<?>, Persister<?>>();
         DbFacade() {
              persisters.put(Holiday.class, new HolidayPersister());
         //This is where I'm stuck
         //I don't want to add supresswarnings to this method, so what should I do?
         public <E> Collection<E> selectAll(Class<E> clazz) {
              //The following line gives:
              //Persister is a raw type. References to generic type
              //Persister<T> should be parameterized
              Persister persister = persisters.get(clazz);
              //The following line gives:
              //Type safety: The expression of type List needs unchecked
              //conversion to conform to Collection<E>
              Collection<E> result = persister.selectAll(clazz);
              return result;
    interface Persister<T> {
         List<T> selectAll(Class<T> clazz);
    abstract class AbstractPersister<T> implements Persister<T> {
    class HolidayPersister extends AbstractPersister<Holiday> {
         public List<Holiday> selectAll(Class<Holiday> clazz) {
              return null;
    class Holiday {
         //data
    }

    Well you can put in a type cast
    Persister<E> pesister = (Persister<E>) persisters.get(clazz);but you'll stil get a warning. Sometimes there's just no avoiding them. What, AFAIK, you can't tell the compiler is that each entry of the map contains a persister for the class mapped to it.
    All it knows that classes are mapped to Persisters.

  • Problem with native SQL cursor in generic data source

    Hi, All!
    I am implementing generic data source based on FM.
    Because of complicated SQL I canu2019t use Open SQL and RSAX_BIW_GET_DATA_SIMPLE-example u201Cas isu201D.
    So, I have to use Native SQL. But Iu2019ve got a problem with a cursor. When I test my data source in RSA3, everything is Ok. But, if I start appropriate info-package, I get error u201CABAP/4 processor: DBIF_DSQL2_INVALID_CURSORu201D. It happens after selecting of 1st data package in line u201CFETCH NEXT S1 INTOu2026u201D. It seems to me that when system performs the second call of my FM the opened cursor has already been disappeared.
    Did anyone do things like this and what is incorrect?
    Is it real to make generic data source based on FM with using Native SQL open, fetch, closeu2026

    Hi Jason,
    I don't think this SQL is very valuable It is just an aggregation with some custom rules. This aggregation is performing on info-provider which consists of two info-cubes. Here we have about 2 billion records in info-provider and about 30 million records in custom db-table Z_TMP (certainly, it has indexes). I have to do this operation on 21 info-providers like this and I have to do this 20 times for each info-provider (with different values of host-variable p_GROUP)
    SELECT T.T1, SUM( T.T2 ), SUM( T.T3 ), SUM( T.T4 )
            FROM (
                    SELECT F."KEY_EVENT06088" AS T1,
                            F."/BIC/EV_COST" + F."/BIC/EV_A_COST" AS T2,
                            DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_COST") +
                              DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_A_COST") AS T3,
                            DECODE( D.SID_EVENTTYPE, 23147, F."/BIC/EV_DURAT",
                                                          23148, F."/BIC/EV_DURAT",
                                                          23151, F."/BIC/EV_DURAT",
                                                          23153, F."/BIC/EV_DURAT",
                                                          23157, F."/BIC/EV_DURAT",
                                                          23159, F."/BIC/EV_DURAT",
                                                          24896734, F."/BIC/EV_DURAT",
                                                          695032768, F."/BIC/EV_DURAT",
                                                          695029006, F."/BIC/EV_DURAT",
                                                          695029007, F."/BIC/EV_DURAT",
                                                          695036746, F."/BIC/EV_DURAT", 0) AS T4
                      FROM "/BIC/VEVENT0608F" F,
                           Z_TMP G,
                           "/BIC/DEVENT06085" D
                      WHERE F."KEY_EVENT06088" = G.ID
                            AND F."KEY_EVENT06085" = D.DIMID
                            AND G.GROUP_NO = :p_GROUP
                            AND ( F."/BIC/EV_COST" < 0 OR F."/BIC/EV_A_COST" < 0 )
                            AND D.SID_EVENTTYPE <> 695030676 AND D.SID_EVENTTYPE <> 695030678
                    UNION
                    SELECT F."KEY_EVNA06088" AS T1,
                            F."/BIC/EV_COST" + F."/BIC/EV_A_COST" AS T2,
                            DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_COST") +
                              DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_A_COST") AS T3,
                            DECODE( D.SID_EVENTTYPE, 23147, F."/BIC/EV_DURAT",
                                                          23148, F."/BIC/EV_DURAT",
                                                          23151, F."/BIC/EV_DURAT",
                                                          23153, F."/BIC/EV_DURAT",
                                                          23157, F."/BIC/EV_DURAT",
                                                          23159, F."/BIC/EV_DURAT",
                                                          24896734, F."/BIC/EV_DURAT",
                                                          695032768, F."/BIC/EV_DURAT",
                                                          695029006, F."/BIC/EV_DURAT",
                                                          695029007, F."/BIC/EV_DURAT",
                                                          695036746, F."/BIC/EV_DURAT", 0) AS T4
                    FROM "/BIC/VEVNA0608F" F,
                         Z_TMP G,
                         "/BIC/DEVNA06085" D
                    WHERE F."KEY_EVNA06088" = G.ID
                          AND F."KEY_EVNA06085" = D.DIMID
                          AND G.GROUP_NO = :p_GROUP
                          AND ( F."/BIC/EV_COST" < 0 OR F."/BIC/EV_A_COST" < 0 )
                          AND D.SID_EVENTTYPE <> 695030676 AND D.SID_EVENTTYPE <> 695030678
                 ) T
            GROUP BY T.T1

  • Problems with Generics

    Ok, I have a problem with the <? extends NamedType> generic parameterized type, here are three example classes:
    public abstract class Base
         public abstract <? extends Base> getMe();
    public abstract class Spec
    extends Base
         public abstract <? extends Spec> getMe();
    public class Impl
    extends Spec
         public Impl()
              super();
         public Impl getMe()
              return this;
         public String toString()
              return "I live!";
    }And a main method in another class:
    public static void main(String[] args)
         Impl im = new Impl();
         Impl i = im.getMe();
         Spec s = Spec.getMe();
         Base b = Base.getMe();
         System.out.println("im = "+im);
         System.out.println("i = "+i);
         System.out.println("s = "+s);
         System.out.println("b = "+b);
    }And the compiler returns this:
    Base.java:3: <identifier> expected
            public abstract <? extends Base> getMe();
                             ^
    Base.java:3: > expected
            public abstract <? extends Base> getMe();
                                                    ^
    Spec.java:4: <identifier> expected
            public abstract <? extends Spec> getMe();
                             ^
    Spec.java:4: > expected
            public abstract <? extends Spec> getMe();
                                                    ^
    4 errorsPlease assist.

    It worked!
    I don't know why that didn't work in Eclipse, so:
    "Return types are compatible if the overriden method's return type is a subclass of the original method's return type."
    I also mistyped the main method, but this new one didn't change the original error:
    public static void main(String[] args)
         Impl im = new Impl();
         Impl i = im.getMe();
         Spec s = Spec.getMe();
         Base b = Base.getMe();
         System.out.println("im = "+im);
         System.out.println("i = "+i);
         System.out.println("s = "+s);
         System.out.println("b = "+b);
    }should be:
    public static void main(String[] args)
         Impl im = new Impl();
         Impl i = im.getMe();
         Spec s = i.getMe();
         Base b = s.getMe();
         System.out.println("im = "+im);
         System.out.println("i = "+i);
         System.out.println("s = "+s);
         System.out.println("b = "+b);
    }

Maybe you are looking for