Incompatible Types... NOT!

Why am I getting incompatible types in this method?
C:\jdk1.3\src\CalcBusinessDays.java:53: incompatible types
found : java.util.Date
required: Date
          Date covDate = sdf.parse(dt, pos);^ <-- carat is at end of line
     public Date dateConvert(String dt) {
          SimpleDateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
          ParsePosition pos = new ParsePosition(0);
          Date covDate = sdf.parse(dt, pos);
          return covDate;
     }     //dateConvert
Thanks in advance.

Actually I'm in Hartford, CT, where NJ sends its rain! I used to live in Staten Island which is close to NJ as you know. Also worked in Parsippany for a while.
I think "Date" needs to be changed to "java.util.Date" in three places. See comments below where changes are marked. I could not compile or test because I don't have Domino / Notes.
By the way, in case you get similar problems with another class (Calendar?), I believe that the lotus.domino classes are AgentBase, AgentContext, Session and DateTime. The others should be standard Java classes. Good Luck.
import java.util.*;
import java.text.*;
import java.math.*;
import lotus.domino.*;
public class CalcBusinessDays extends AgentBase {
    public void NotesMain() {
        DateTime startTime = null, endTime = null;
        String startTimeStr, endTimeStr, result;
        try {
            Session session = getSession();
            AgentContext agentContext = session.getAgentContext();
            startTimeStr = "04/12/2000";
            endTimeStr = "05/04/2000";
            startTime = session.createDateTime(startTimeStr);
            endTime = session.createDateTime(endTimeStr);
            result = diffInWeekdays(startTime, endTime, startTimeStr,
            endTimeStr);
            System.out.println("Result = " + result);
        } catch(Exception e) {
            e.printStackTrace();
    } //NotesMain
    public String diffInWeekdays(DateTime startTime, DateTime endTime, String startTimeStr, String endTimeStr) {
        String res = "";
        try {
            Date firstDate = null, secondDate = null;
            int diffInt = endTime.timeDifference(startTime);
            int diffIntDays = (diffInt / 86400 + 1);
            BigInteger sev = BigInteger.valueOf(7);
            BigInteger minusTwo = BigInteger.valueOf(-2);
            BigInteger bis = BigInteger.valueOf(getWeekday(firstDate = dateConvert(startTimeStr)));
            BigInteger bie = BigInteger.valueOf(getWeekday(secondDate = dateConvert(endTimeStr)));
            int strtDay = bis.mod(sev).intValue();
            int endDay = bie.mod(sev).intValue();
            int max = minusTwo.max(BigInteger.valueOf(strtDay * -1)).intValue();
            int min = BigInteger.valueOf(1).min(bie.mod(sev)).intValue();
            int result = (diffIntDays - endDay + strtDay - 8) * 5 / 7 - max - min + 5 - strtDay + endDay;
            //o.println("result =\t" + result);
            res = Integer.toString(result);
        } catch (Exception e) {
            e.printStackTrace();
        return res;
    } //diffInWeekdays
    public java.util.Date dateConvert(String dt) {          // *** changed
        SimpleDateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
        ParsePosition pos = new ParsePosition(0);
        java.util.Date covDate = sdf.parse(dt, pos);       // *** changed
        return covDate;
    } //dateConvert
    public int getWeekday(java.util.Date cdt) {            // *** changed
        Calendar cal = Calendar.getInstance();
        cal.setTime(cdt);
        return cal.get(Calendar.DAY_OF_WEEK);
    } //getWeekday
} //CalcBusinessDays

Similar Messages

  • Incompatible types with generics problem

    Hi,
    I get a mysterious compiler error:
    C:\Documents and Settings\Eigenaar\Mijn documenten\NetBeansProjects\Tests\src\tests\genericstest.java:26: incompatible types
    found : tests.Store<T>
    required: tests.Store<T>
    return store;
    1 error
    BUILD FAILED (total time: 0 seconds)
    in the following code:
    class Supply<T extends Supply<T>>{}
    class Store<T extends Supply<T>>{ }
    class A<T extends Supply<T>>{
        private Store<T> store;
        class B<T extends Supply<T>> {
            public Store<T> getStore(){
                return store;                         <-- compiler error!
    }Any help would be greatly appreciated.
    Edited by: farcat on Jan 13, 2009 1:23 PM

    Note that the type parameter T used to define class B is not the T used to define class A. What you wrote can be more clearly written:
    class Supply<T extends Supply<T>>{}
    class Store<T extends Supply<T>>{ }
    class A<T extends Supply<T>>{
        private Store<T> store;
        class B<U extends Supply<U>> {
            public Store<U> getStore(){
                return store;
    }Which produces the more readable error message:
    A.java:10: incompatible types
    found   : Store<T>
    required: Store<U>
                return store;B, being a nested, non-static class is already parameterized by T:
    class Supply<T extends Supply<T>>{}
    class Store<T extends Supply<T>>{ }
    class A<T extends Supply<T>>{
        private Store<T> store;
        class B {
            public Store<T> getStore(){
                return store;
    }

  • ORABPEL-10041 Trying to assign incompatible types

    Hi,
    I'm developing a BPEL process which takes an input xml file and inserts data into AP interface tables. I used a file adapter to read the input file and used applications adapter to import ap interface tables.
    I use the assign activity to assign the number value from my xml file to the invoice_id column in the ap_invoices_interface column. I get the following warning. Can anyone please tell me how do I fix this. I have BPEL 10.1.2.2 installed.
    Warning(29):
    [Error ORABPEL-10041]: Trying to assign incompatible types
    [Description]: in line 29 of "C:\OraBPELPM_1\integration\jdev\jdev\mywork\Workspace1\BPELProcess_TestInsert\BPELProcess_TestInsert.bpel", <from> value type "{http://www.w3.org/2001/XMLSchema}string" is not compatible with <to> value type "{http://www.w3.org/2001/XMLSchema}long".
    [Potential fix]: Please make sure that the return value of from-spec query is compatible with the to-spec query.
    Thanks

    This is just a warning so it does not mean that your process will fail, e.g. string to decimal may work for the string holds a number, but will fail if it has a string.
    So if you know the data you can safely ignore, otherwise you will have to do some transofrmation within an assign.
    cheers
    James

  • Incompatible  types

    I get the following error message:
    headoffice.java:181: incompatible types
    found : java.lang.String
    required: int
    switch (sa[3]) //sa[3] contains customer type
    ^
    headoffice.java:183: incompatible types
    found : java.lang.String
    required: int
    case �B�:
    ^
    headoffice.java:186: incompatible types
    found : java.lang.String
    required: int
    case �G�:
    ^
    3 errors
    ...and it is associated with the piece of code below. I do not understand in what way the �G� and �B� are incompatible types with sa[3] which is supposed to hold strings.
    StringTokenizer st=new StringTokenizer(s, �*�);     
    String[] sa=new String[st.countTokens()]; int i=0;          
    while(st.hasMoreTokens())
    sa=st.nextToken();     
    i++;               
    switch (sa[3]) //sa[3] contains customer type
    case �B�:
    BronzeCustomer anotherBronzeCustomer = new BronzeCustomer(sa[0], sa[1]);     break;
    case �G�:
    GoldCustomer anotherGoldCustomer = new GoldCustomer(sa[0], sa[1]);     break;
    default: return;
    // break;     
    What is the problem here?
    Regards
    TJ

    If you are using only 1-character strings, then you can do:
       switch (sa[3].charAt(0)) //sa[3] contains customer type
          case 'B': // ...
          case 'G': // ...
          // etc.
       }

  • Incompatible type error

    I am receiving the following errors:
    incompatible types
    found: int
    required: boolean
    if (accessCode = 8345)
    if (accessCode = 55875)
    if (accessCode = 999909)
    I do not understand why I am getting the errors. accessCode is of type int.
    Thanks in advance for any input.
    int accessCode = Integer.parseInt( String.valueOf(
      securityCodeJPasswordField.getPassword() ) );
         int code;
         if (accessCode >= 1645 && accessCode <= 1689)
             code = 1;
         else
         if (accessCode  = 8345)
                code = 2;
         else
         if (accessCode = 55875)
             code = 3;
         else
         if (accessCode = 999898)
             code = 4;
         else
         if (accessCode >= 1000006 && accessCode <= 1000008)
             code = 5;
         else
         if (accessCode < 1000)
             code = 6;
         else
                        code = accessCode;

    Thanks !! I am stuck in the coding syntax that I use in my job: SAS

  • Error in Parser.fx file "incompatible types found   : java.util.Properties"

    Hi,
    In parser file "Parser.fx",
    public-read def PROPERTIES_PARSER = StreamParser {
    override public function parse(input : java.io.InputStream) : RecordSet {
    var props = javafx.util.Properties {};
    props.load(input);
    input.close();
    MemoryRecordSet {
    records: [
    MapRecord {
    fields: props
    due to under line portion an error is appearing:
    "incompatible types
    found : javafx.util.Properties
    required: java.util.Map
    fields: props".
    Please suggest some solution.
    Thanks in advance.
    regards,
    Choudhary Nafees Ahmed
    Edited by: ChoudharyNafees on Jul 5, 2010 3:48 AM

    Parser.fx
    package org.netbeans.javafx.datasrc;
    import javafx.data.pull.PullParser;
    import javafx.data.pull.Event;
    import org.netbeans.javafx.datasrc.MemoryRecordSet;
    public-read def PROPERTIES_PARSER = StreamParser {
        override public function parse(input : java.io.InputStream) : RecordSet {
            var props =java.util.Properties{};
            props.load(input);
            input.close();
            MemoryRecordSet {
                records: [
                    MapRecord {
                        fields: props
    public-read def LINE_PARSER_FIELD_LINE = ".line";
    public-read def LINE_PARSER = StreamParser {
        override public function parse(input : java.io.Reader) : RecordSet {
            var line : String;
            var result : Record [] = [];
            line = readLine(input);
            // BEWARE  ("" == null) is true
            while (line != null or "".equals(line)) {
                var map = new java.util.HashMap();
                map.put(LINE_PARSER_FIELD_LINE, line);
                var record = MapRecord {
                    fields: map
                insert record into result;
                line = readLine(input);
            MemoryRecordSet {
                records: result
    function readLine(in : java.io.Reader) : String {
        var str = new java.lang.StringBuilder;
        while (true) {
            var c = in.read();
            if (c == -1) {
                return if (str.length() == 0) then null else str.toString();
            } else if (c == 0x0D) {
                c = in.read();
                if (c == 0x0A or c == -1) {
                    return str.toString();
                str.append(0x0D);
            } else if (c == 0x0A) {
                return str.toString();
            str.append(c as Character);
        str.toString()
    public-read def JSON_PARSER = StreamParser {
        function toSequence(list : java.util.List) : Record [] {
            var result : Record [] = [];
            var ii = list.iterator();
            while (ii.hasNext()) {
                var r = ii.next() as Record;
                insert r into result;
            result
        override public function parse(input : java.io.InputStream) : RecordSet {
            var topLevel : Object;
            def parser = PullParser {
                documentType: PullParser.JSON
                input: input
                var mapStack = new java.util.Stack();
                var currentMap : java.util.Map;
                var recordsStack = new java.util.Stack();
                var currentRecords : java.util.List;
                var lastEvent: Event;
                onEvent: function(event: Event) {
                    if (event.type == PullParser.TEXT) {
                        currentMap.put(event.name, event.text)
                    } else if (event.type == PullParser.INTEGER) {
                        currentMap.put(event.name, event.integerValue)
                    } else if (event.type == PullParser.NULL) {
                        currentMap.put(event.name, null)
                    } else if (event.type == PullParser.START_ELEMENT) {
                        if (lastEvent.type == PullParser.START_ARRAY_ELEMENT) return;
                        var oldMap = currentMap;
                        var temp = new java.util.HashMap();
                        temp.put(new Object(), null);
                        currentMap = temp;
                        currentMap.clear();
                        mapStack.push(currentMap);
                        if (topLevel == null) topLevel = currentMap;
                        if (oldMap != null) {
                            var mr = MapRecord {
                                fields: currentMap
                            if (event.name == "" and lastEvent.type == PullParser.START_VALUE) {
                                oldMap.put(lastEvent.name, mr)
                            } else {
                                oldMap.put(event.name, mr)
                    } else if (event.type == PullParser.START_ARRAY_ELEMENT) {
                        var temp = new java.util.HashMap();
                        temp.put(new Object(), null);
                        currentMap = temp;
                        currentMap.clear();
                        mapStack.push(currentMap);
                        var mr = MapRecord {
                            fields: currentMap
                        currentRecords.add(mr);
                    } else if (event.type == PullParser.END_ELEMENT) {
                        mapStack.pop();
                        if (not mapStack.empty()) {
                            currentMap = mapStack.peek() as java.util.HashMap;
                        } else {
                            currentMap = null;
                    } else if (event.type == PullParser.END_ARRAY_ELEMENT) {
                        if (lastEvent.type == PullParser.END_ELEMENT) return;
                        mapStack.pop();
                        if (not mapStack.empty()) {
                            currentMap = mapStack.peek() as java.util.HashMap;
                        } else {
                            currentMap = null;
                    } else if (event.type == PullParser.START_ARRAY) {
                        currentRecords = new java.util.ArrayList();
                        recordsStack.push(currentRecords);
                        if (topLevel == null) topLevel = currentRecords;
                    } else if (event.type == PullParser.END_ARRAY) {
                        var set = MemoryRecordSet {
                            records: toSequence(currentRecords)
                        currentMap.put(event.name, set);
                        recordsStack.pop();
                        if (not recordsStack.empty()) {
                            currentRecords = recordsStack.peek() as java.util.List;
                        } else {
                            currentRecords = null;
                    lastEvent = event;
            parser.parse();
            if (topLevel instanceof java.util.Map) {
                var mr = MapRecord {
                    fields: topLevel as java.util.Map
                MemoryRecordSet {
                   records: [mr]
            } else {
                // List
                var rs = MemoryRecordSet {
                    records: toSequence(topLevel as java.util.List)
                rs
            parser.parse();
            var mr = MapRecord {
                fields: topLevel as java.util.Map
            MemoryRecordSet {
               records: [mr]

  • Incompatible types in simple odbc statements

    this is my simple code
    import java.sql.*;
    public class QueryApp {
         public static void main(String a[]){
              try{
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   Connection con;
                   con=DriverManager.getConnection("jdbc:odbc:MyDataSource","nik","123456");
                   Statement stat=con.createStatement();
                   stat.executeQuery("Select * from Publishers");
              catch(Exception e){
                   System.out.println("Error:"+e);
    }after this when i compile i get these errors
    QueryApp.java:15: incompatible types
    found   : java.sql.Connection
    required: Connection
                con=DriverManager.getConnection("jdbc:odbc:MyDataSource","nik","123456");
                                                           ^
    QueryApp.java:16: cannot find symbol
    symbol  : method createStatement()
    location: class Connection
                Statement stat=con.createStatement();
                                              ^
    2 errorsCan some body help me on this error as searching on net wasn't fruitfull?

    1) You probably created a Connection class your compiler tries to use instead of java.sql.Connection. I advise to rename your class, or at least use the fully qualified classname for declaring con.
    2) The Connection class you created does not have such a method.

  • Incompatible types error on a for loop

    Hi. I am in the middle of making a program and a decided to make a print statment to check to make sure everything was organized as it should be and I got an incompatible types error for the line where I start my for loop - for (index = 0 ...) etc. Since everything is an int, I'm not sure how they're not compatible with each other.. thoughts? here's my code so far, thanks
    import java.io.*; // needed for stream readers
    import java.lang.*;
    public class testScores extends Object
         public static void main(String args[] ) throws Exception
         // declare variables for input
    String      records;
    String      room_nbr_input;
    String      test_score_input;
    String      student_id;
    int          room_nbr_nbr;
    int          test_score_nbr;
    int          index;
    String[] record = new String[3];
    int[]     room_nbr = new int[30];
    int[]      test_score = new int[30];
    int[]     kount = new int[30];
         // created file reader and buffered reader
              FileReader frM;
              BufferedReader brM;
              // open file
              frM = new FileReader("einstein_testscores_2009.txt");
              brM = new BufferedReader(frM);
         // print headings
              startUp();
              // get one record from file
              records = brM.readLine();
              while(records !=null)
              //split the record into three fields = the array record[], then assign those values to variables
              record = records.split(", ");
              student_id = record[0];
              room_nbr_input = record[1];
              test_score_input = record[2];
              //change the data into integers
              room_nbr_nbr = Integer.parseInt(room_nbr_input);
              test_score_nbr = Integer.parseInt(test_score_input);
              //put the variables into arrays
              room_nbr[room_nbr_nbr -1] = room_nbr_nbr;
              test_score[room_nbr_nbr -1] = test_score[room_nbr_nbr -1] + test_score_nbr;
              //get new record
              records = brM.readLine();
              for (index = 0; index = room_nbr.length; index++)
                   System.out.print(room_nbr[index] + "\t\t" + test_score[index]);
         public static void startUp()
         System.out.print("Einstein Elementary Test Scores\n\n");
         System.out.print("Room Number\t\tTest Score Average\n\n");
    }          // end of class declaration

    thank you. here's the code.
    import java.io.*;       // needed for stream readers
    import java.lang.*;   
    public class testScores extends Object
         public static void main(String args[] ) throws Exception
         // declare variables for input
            String      records;
            String      room_nbr_input;
            String      test_score_input;
            String      student_id;
            int             room_nbr_nbr;
            int             test_score_nbr;
            int          index;
            String[] record = new String[3];
            int[]      room_nbr = new int[30];
            int[]       test_score = new int[30];
            int[]      kount = new int[30];
              // created file reader and buffered reader
              FileReader frM;
              BufferedReader brM;
              // open file
              frM = new FileReader("einstein_testscores_2009.txt");
              brM = new BufferedReader(frM);
         // print headings
              startUp();
              // get one record from file
              records = brM.readLine();
              while(records !=null)
              //split the record into three fields = the array record[], then assign those values to variables
              record = records.split(", ");
              student_id = record[0];
              room_nbr_input = record[1];
              test_score_input = record[2];
              //change the data into integers
              room_nbr_nbr = Integer.parseInt(room_nbr_input);
              test_score_nbr = Integer.parseInt(test_score_input);
              //put the variables into arrays
              room_nbr[room_nbr_nbr -1] = room_nbr_nbr;
              test_score[room_nbr_nbr -1] = test_score[room_nbr_nbr -1] + test_score_nbr;
              //get new record
              records = brM.readLine();
               for (index = 0; index = room_nbr.length; index++)
                    System.out.print(room_nbr[index] + "\t\t" + test_score[index]);
         public static void startUp()
         System.out.print("Einstein Elementary Test Scores\n\n");
         System.out.print("Room Number\t\tTest Score Average\n\n");
    }          // end of class declaration

  • Compatible & Incompatible types

    Why is that I can assign a integer value to a double variable, but cannot assign a double value to an integer variable? Aren't double and integer compatible types? Isn't there a concept of truncation in java? I searched the net but in vain. I couldn't find the exact answer I was looking for. So I am posting in this forum.
    PS: I understand it is not possible to assign an integer to a string since they are incompatible types.
    Edited by: 964980 on Mar 26, 2013 9:29 PM

    Why is that I can assign a integer value to a double variableBecause it's a widening conversion that doesn't lose any information. See JLS #5.1.2.
    but cannot assign a double value to an integer variable?Because it's a narrowing conversion that might lose information. You can do it as long as you write an explicit typecast. See JLS #5.1.3.
    Aren't double and integer compatible types?No, see above.
    Isn't there a concept of truncation in java?Yes, see above.
    @rp0428 I don't see what good asking for the code and the error message does, in a fundamental case like this. It doesn't change the answer, and your own answer (is/isn't) wasn't too inspiring.

  • Compiler error: incompatible types

    When I try to compile this code it gives the error "incompatible types".
    import java.util.ArrayList;
    public class Poly {
         public static void main (String args[]) {
              Number integer = new Integer(1);
              ArrayList<Number> integers = new ArrayList<Integer>();
    }Assigning a Number object an Integer which extends Number works fine.
    But when I try to assign an ArrayList<Number> object an ArrayList<Integer> object it gives an imcompatible types error.
    Shouldn't it work?
    Edited by: aexyl93 on Jun 7, 2010 2:00 AM
    Edited by: aexyl93 on Jun 7, 2010 2:05 AM

    aexyl93 wrote:
    Thanks for the quick replies.
    I've never seen ArrayList<? extends obj> before.Nitpick: it's not "? extends obj" it's "? extends SomeClass".
    "obj" kind of implies that you could use a variable/field here, which is wrong.
    I thought it would be able to hold an object which extends what it's supposed to hold.A List<? extends Number> could contain any class that extends Number (as well as Number itself if it weren't an abstract class). However you can't add anything (except null), because you don't know the concrete type at this point.

  • Error(86,88): incompatible types; found: java.util.ArrayList

    Hi,
    I'm getting following error :
    Error(86,88): incompatible types; found: java.util.ArrayList, required: com.sun.java.util.collections.ArrayList
    The line JDev is complaining about contains the following code :
    com.sun.java.util.collections.ArrayList runtimeErrors = container.getExceptionsList();
    I really don't have a clue where this error comes from. If I right-click on ArrayList it brings me to the correct declaration.
    Does somebody know what I'm doing wrong?
    Thanks in advance for you help!
    Kris

    Kris,
    try changing the code to :
    java.util.ArrayList runtimeErrors = container.getExceptionsList();apparently container.getExceptionsList() returns a java.util.Arraylist not a com.sun.java.util.collections.ArrayList
    HTH,
    John

  • Incompatible types (Generics)

    Can someone explain me please the following message I've got when trying to compile a file?
    incompatible types
    found : java.util.Iterator<E1>
    required: java.util.Iterator<E1>
    If the types are identical, how can they be incompatible???!!!
    Thanks.

    Hello,
    I am stuck, I have a compilation probem. I am trying to compile my torque init class, and it gave an error message says that incompatible types. I am using Vector package to check the index of an element in the array. But the compiler found List instead of vector. Can you please tell me what's wrong.
    // Begin MyProject.java source
    package com.digitalevergreen.mytest;
    import com.digitalevergreen.mytest.om.*;
    import org.apache.torque.Torque;
    import org.apache.torque.util.Criteria;
    import java.util.Vector;
    public class MyProject
    public static void main(String[] args)
    try
    // Initialze Torque
    Torque.init( "C:/Project/torque-3.1/Project.properties" );
    // Create some Authors
    Author de = new Author();
    de.setFirstName( "David" );
    de.setLastName( "Eddings" );
    de.save();
    Author tg = new Author();
    tg.setFirstName( "Terry" );
    tg.setLastName( "Goodkind" );
    tg.save();
    // Create publishers
    Publisher b = new Publisher();
    b.setName( "Ballantine" );
    b.save();
    Publisher t = new Publisher();
    t.setName( "Tor" );
    t.save();
    // Ok. For some reason even though the BaseXPeer doInsert
    // methods return the primary key it is not set in the
    // BaseX save method so we have to "retrieve" these objects
    // from the database or we will get null value exceptions
    // when we try to use them in the book objects and do a save.
    Criteria crit = new Criteria();
    crit.add( AuthorPeer.LAST_NAME, "Eddings" );
    Vector v = AuthorPeer.doSelect( crit );
    if ( v != null && v.size() > 0 )
    de = (Author) v.elementAt(0);
    crit = new Criteria();
    crit.add( AuthorPeer.LAST_NAME, "Goodkind" );
    v = AuthorPeer.doSelect( crit );
    if ( v != null && v.size() > 0 )
    tg = (Author) v.elementAt(0);
    crit = new Criteria();
    crit.add( PublisherPeer.NAME, "Ballantine" );
    v = PublisherPeer.doSelect( crit );
    if ( v != null && v.size() > 0 )
    b = (Publisher) v.elementAt(0);
    crit = new Criteria();
    crit.add( PublisherPeer.NAME, "Tor" );
    v = PublisherPeer.doSelect( crit );
    if ( v != null && v.size() > 0 )
    t = (Publisher) v.elementAt(0);
    // Create books
    Book wfr = new Book();
    wfr.setTitle( "Wizards First Rule" );
    wfr.setCopyright( "1994" );
    wfr.setISBN( "0-812-54805-1" );
    wfr.setPublisher( t );
    wfr.setAuthor( tg );
    wfr.save();
    Book dof = new Book();
    dof.setTitle( "Domes of Fire" );
    dof.setCopyright( "1992" );
    dof.setISBN( "0-345-38327-3" );
    dof.setPublisher( b );
    dof.setAuthor( de );
    dof.save();
    // Get and print books from db
    crit = new Criteria();
    v = BookPeer.doSelect( crit );
    for ( int i = 0; i < v.size(); i++ )
    Book book = (Book) v.elementAt(i);
    System.out.println("Title: " + book.getTitle() );
    System.out.println("Author: " +
    book.getAuthor().getFirstName()
    + " " +
    book.getAuthor().getLastName() );
    System.out.println("Publisher: " +
    book.getPublisher().getName() );
    System.out.println("\n\n");
    catch (Exception e)
    e.printStackTrace();
    // End MyProject.java source
    and this is the error message:
    C:\Project\torque-3.1\src\java\com\digitalevergreen\mytest>javac MyProject.java
    MyProject.java:50: incompatible types
    found : java.util.List
    required: java.util.Vector
    Vector v = AuthorPeer.doSelect( crit );
    ^
    MyProject.java:56: incompatible types
    found : java.util.List
    required: java.util.Vector
    v = AuthorPeer.doSelect( crit );
    ^
    MyProject.java:62: incompatible types
    found : java.util.List
    required: java.util.Vector
    v = PublisherPeer.doSelect( crit );
    ^
    MyProject.java:68: incompatible types
    found : java.util.List
    required: java.util.Vector
    v = PublisherPeer.doSelect( crit );
    ^
    MyProject.java:93: incompatible types
    found : java.util.List
    required: java.util.Vector
    v = BookPeer.doSelect( crit );
    ^
    5 errors
    C:\Project\torque-3.1\src\java\com\digitalevergreen\mytest>
    any help will be appreciated. Thank you in advance.
    Omar N.

  • Help on Incompatible types

    Sample 1:
    public interface I<T extends I<?>>
      I<? extends I<T>> m1 ();
    public class Z<T extends I<?>> implements I<T>
      public I<? extends I<T>> m1 ()
        return m2();
      protected I<? extends I<T>> m2 ()
        return null;
    javac Z.javacompiled with no problems
    Sample 2:
    public interface I<Tx, T extends I<Tx, ?>>
      I<Tx, ? extends I<Tx, T>> m1 ();
    public class Z<Tx, T extends I<Tx, ?>> implements I<Tx, T>
      public I<Tx, ? extends I<Tx, T>> m1 ()
        return m2();
      protected I<Tx, ? extends I<Tx, T>> m2 ()
        return null;
    javac Z.javaZ.java:5: incompatible types
    found : I<Tx,capture of ? extends I<Tx,T>>
    required: I<Tx,? extends I<Tx,T>>
    return m2();
    ^
    1 error
    Well... can anyone help with this? Or at least some explanations why adding second generic generates this problem?

    The problem is in the recursion, not in the second type argument. If you changed your first interface from
        public interface I<T extends I<?>> {} to
        public interface I<T extends I<T>> {} you would run into the same error message. For sake of clarity let's discuss the issue using your first example in a slightly simplified form:
        public interface I<T extends I<T>> {}
        public class Z<E>
          public I<? extends I<E>> m1 ()
            return m2();
            /* error: incompatible types
               found   : I<capture of ? extends I<E>>
               required: I<? extends I<E>>
               return m2();
                        ^
          protected I<? extends I<E>> m2 ()
          { return null; }
        }The error message is not awfully helpful, because the "E" is different in both types.
    Method m2 returns a reference of type I<capture of ? extends I<E>>, where E extends I<capture of ? extends I<E>>, that is, it returns a concrete instantiation of the interface, namely I<SomeType> with a type that extends I<SomeType> with a type that extends ... continued recursively.
    On the other hand, method m1 is supposed to return a reference of type I<? extends I<E>>, where E extends I<? extends I<E>>, that is, it returns a wildcard instantiation of the interface, namely I<? extends I<SomeType>> with a type that extends I<? extends I<SomeType>> with a type that extends ... continued recursively.
    And here is the point: The first construct leads to a concrete instantiation like a List<List<List<String>>>. The second construct lead to a recursive wildcard instantiation like List<? extends List<? extends List<?>>>. As soon as the wildcard appears on a nested level, the types are no longer compatible.
    It's like assigning a List<List<String>> to a List<List<?>>. It's not permitted because the first is a list of string-lists and the second is a list of mixed-lists. You cannot assign one to the other.
    In your example, changing
        public interface I2<Tx, T extends I2<Tx, ?>> to
        public interface I2<Tx, T extends I2<?, ?>>might do the trick.
    (As usual, ignore the annoying additional angle brackets.)

  • Incompatible types error....plzz help

    the code is
    import java.util.*;
    class a{
    public static void main(String args[]){
    LinkedList list = new LinkedList (  ) ; 
    list.add ( "shiva" ) ; 
    list.add ( "java" ) ; 
    list.add ( "world" ) ; 
    String [  ]   str = list.toArray ( new String [ list.size (  )  ]  ) ;
    }}the error is
    C:\Documents and Settings\Sumit\Desktop>javac a.java
    a.java:11: incompatible types
    found : java.lang.Object[]
    required: java.lang.String[]
    String [  ] str = list.toArray ( new String [ list.size (  )  ] ) ;
    ^
    Note: a.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    1 error
    i am not getting what's wrong with it

    i am not getting what's wrong with itYou're not going to like this advice, but still you must learn to help yourself. If you've not done so, please look at the API on the LinkedList toArray method. If it doesn't make sense to you, then ask specific questions about what in the API you don't understand.

  • Incompatible type on stack

    does anybody have any idea why i am getting an "incompatible type on stack error" when i try to create my stubs?
    thanks!
    peter

    Hi. This is a more precise followup to my posting. I have never
    experienced a VerifyError before, here is the error that i got
    when running rmic on my class file.
    Exception in thread "main", java.lang.VerifyError: verification
    failed at PC 55 in sum.rmi.runtime.log: <clinit>(V()): incompatible
    type on stack.
    I have run a jfc-dump and it seems to have something to do with the
    vector array i have assigned to the RMI clients but i am not to sure
    how to fix it. any suggestions would be appreciated.
    regards,
    peter

Maybe you are looking for

  • Best app to convert dvd to itunes format

    what is the best app to convert dvd to itunes mp4 format

  • Why does Firefox Crash Constantly?

    Like others who have reported this issue, Firefox has been crashing constantly on numerous different websites. I have Windows 7 32bit which was recently re-installed, fully updated. All drivers are up to date, all add-ons are updated, all plug-ins ar

  • Pg_upgrade fails for "$libdir/postgis-2.0"

    Hello I was trying to update my system, when found that postgresql needs a little tweaking from 9.2 to 9.3. Following the instructions on the wiki, I ran pg_upgrade: [26] root@xxxlinux : /home/ognyan $ su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/b

  • NWDS 7.0  SP10 compatible Java JDK

    Hi, I have to install NWDS 7.0 SP10. Can any one tell me whats the correct Java Version will suit for this NWDS. Thanks Vj

  • Save to web not working

    Newbie here! I'll have a photo opened in E7 Edit and when I click on" Save For Web"  nothing happens.  Thanks for any help.