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.

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;
    }

  • Problem with incompatible types

    Can you help me out where the problem is? The Child extends the Iterator<GenericTypeTest> so why the assignment doesn`t work? Thank you in advance
    class GenericTypeTest implements Iterator<GenericTypeTest> {
        public GenericTypeTest() {
            Child a = null;
            Iterator<GenericTypeTest> b = null;
            b = a;
            Set<Child> sa = null;
            Set<Iterator<GenericTypeTest>> sb = null;
            sb = sa; // HERE: COMPILATION PROBLEM
            // (Incompatible types: found: Set<Child> required: Set<Iterator<GenericTypeTest>>)
        public boolean hasNext() {
            return false;
        public GenericTypeTest next() {
            return null;
        public void remove() {
    class Child extends GenericTypeTest {}

    You can only assign from a subtype to a supertype. And the subtype/supertype relationship for generic types isn't what you think it is. Read this FAQ entry for more information, especially the part around the sentence "The prerequisite is that at least one of the involved type arguments is a wildcard."

  • 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.)

  • Cluster resource 'Analysis Services' of type 'Generic Service' in clustered role 'SQL Server' failed.

    Windows Server 2012 R2
    SQL Server 2012
    After a recent cluster failover from node 1 to node 2, the Analysis Services role is in a failed state, with the service stopped. When attempting to start the service, there are two error messages captured in Failover Cluster Manager:
    Log Name:      System
    Source:        Microsoft-Windows-FailoverClustering
    Date:          4/10/2014 11:48:49 AM
    Event ID:      1042
    Task Category: Generic Service Resource
    Level:         Error
    Keywords:      
    User:          SYSTEM
    Computer:      HQ-HASQL-1.sbgnet.int
    Description:
    Generic service 'Analysis Services (HASQL)' failed with error '1067'. Please examine the application event log.
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="Microsoft-Windows-FailoverClustering" Guid="{BAF908EA-3421-4CA9-9B84-6689B8C6F85F}" />
        <EventID>1042</EventID>
        <Version>0</Version>
        <Level>2</Level>
        <Task>16</Task>
        <Opcode>0</Opcode>
        <Keywords>0x8000000000000000</Keywords>
        <TimeCreated SystemTime="2014-04-10T15:48:49.752168200Z" />
        <EventRecordID>26212</EventRecordID>
        <Correlation />
        <Execution ProcessID="9036" ThreadID="14748" />
        <Channel>System</Channel>
        <Computer>HQ-HASQL-1.sbgnet.int</Computer>
        <Security UserID="S-1-5-18" />
      </System>
      <EventData>
        <Data Name="ResourceName">Analysis Services (HASQL)</Data>
        <Data Name="Status">1067</Data>
      </EventData>
    </Event>
    Log Name:      System
    Source:        Microsoft-Windows-FailoverClustering
    Date:          4/10/2014 11:48:49 AM
    Event ID:      1069
    Task Category: Resource Control Manager
    Level:         Error
    Keywords:      
    User:          SYSTEM
    Computer:      HQ-HASQL-1.sbgnet.int
    Description:
    Cluster resource 'Analysis Services (HASQL)' of type 'Generic Service' in clustered role 'SQL Server (HASQL)' failed.
    Based on the failure policies for the resource and role, the cluster service may try to bring the resource online on this node or move the group to another node of the cluster and then restart it.  Check the resource and group state using Failover Cluster
    Manager or the Get-ClusterResource Windows PowerShell cmdlet.
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="Microsoft-Windows-FailoverClustering" Guid="{BAF908EA-3421-4CA9-9B84-6689B8C6F85F}" />
        <EventID>1069</EventID>
        <Version>1</Version>
        <Level>2</Level>
        <Task>3</Task>
        <Opcode>0</Opcode>
        <Keywords>0x8000000000000000</Keywords>
        <TimeCreated SystemTime="2014-04-10T15:48:49.752168200Z" />
        <EventRecordID>26213</EventRecordID>
        <Correlation />
        <Execution ProcessID="6464" ThreadID="9076" />
        <Channel>System</Channel>
        <Computer>HQ-HASQL-1.sbgnet.int</Computer>
        <Security UserID="S-1-5-18" />
      </System>
      <EventData>
        <Data Name="ResourceName">Analysis Services (HASQL)</Data>
        <Data Name="ResourceGroup">SQL Server (HASQL)</Data>
        <Data Name="ResTypeDll">Generic Service</Data>
      </EventData>
    </Event>
    With just these generic error messages being present, this has been difficult to diagnose. Some research has yielded possible resolutions of the Event Viewer log being full, .NET corruption, missing registry entries, but none of those seem to be the issue
    (Event Viewer logs cleared, Analysis services is working on the same physical servers in a different cluster, and the registry entries was only a supported issue for SQL Server 2008 and 2008 R2).
    Any help would be greatly appreciated.

    Bring up Configuration Manager, look at binary path for SSAS.  Make sure BOTH folders exist.  Sometimes with failovers mappings get screwed up.

  • Incompatible types - found java.lang.String but expected int

    This is an extremely small simple program but i keep getting an "incompatible types - found java.lang.String but expected int" error and dont understand why. Im still pretty new to Java so it might just be something stupid im over looking...
    import java.io.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class Lab
    public static void main(String []args)
    int input = JOptionPane.showInputDialog("Input Decimal ");
    String bin = Integer.toBinaryString(input);
    String hex = Integer.toHexString(input);
    System.out.println("Decimal= " + input + '\n' + "Binary= " + bin + '\n' + "Hexadecimal " + hex);
    }

    You should always post the full, exact error message.
    Your error message probably says that the error occurred on something like line #10, the JOptionPane line. The error is telling you that the compiler found a String value, but an int value was expected.
    If you go to the API docs for JOptionPane, it will tell you what value type is returned for showInputDialog(). The value type is String. But you are trying to assign that value to an int. You can't do that.
    You will need to assign the showInputDialog() value to a String variable. Then use Integer.parseInt(the_string) to convert to an int value.

  • Incompatible types in case statement

    I'm getting incompatible types inside this case statement :
    inString = s_in.readUTF();
                switch (inString.substring(1,3))
                    case nam:
                        ChatClient.nameArea.append(inString);
                        break;
                    case txt:
                        ChatClient.chatArea.append( "\n >>>" + inString );
                        break;
                }If you want, or need to see more or all of the code in this class, just ask.

    This is because you can't use Strings within a switch statement. Use if statements instead.

  • Incompatible types - found, required...

    Experts,
    I am getting the following failure. What am I missing?
    Javac output,
    #javac .\org\ocap\dvr\*.java
    .\org\ocap\dvr\TestRecord.java:123: incompatible types
    found : org.ocap.shared.dvr.RecordingManager
    required: org.ocap.dvr.OcapRecordingManager
    recManager = OcapRecordingManager.getInstance();
    ^
    The source code is as follows,
    In .\src\org\ocap\shared\dvr\RecordingManager.java
    ----------------- START --------------------
    package org.ocap.shared.dvr;
    public abstract class RecordingManager
    public static RecordingManager getInstance()
    return null;
    // stuff deleted
    ------------------ END -------------------
    In .\src\org\ocap\dvr\OcapRecordingManager.java
    ----------------- START --------------------
    package org.ocap.dvr;
    import org.ocap.dvr.*;
    import org.ocap.shared.dvr.*;
    public abstract class OcapRecordingManager extends RecordingManager
    // stuff deleted
    ------------------ END -------------------
    In .\src\org\ocap\dvr\OcapRecordingManagerImpl.java
    ----------------- START --------------------
    package org.ocap.dvr;
    import org.ocap.dvr.*;
    import org.ocap.shared.dvr.*;
    public class OcapRecordingManagerImpl extends OcapRecordingManager
    private static OcapRecordingManager mOcapRecordingManager = null;
    public static OcapRecordingManager getInstance()
    if (mOcapRecordingManager == null)
    mOcapRecordingManager = new OcapRecordingManagerImpl();
    return mOcapRecordingManager;
    ------------------ END -------------------
    In .\src\org\ocap\dvr\TestRecord.java
    ----------------- START --------------------
    package org.ocap.dvr;
    import org.ocap.dvr.OcapRecordingManager;
    import org.ocap.shared.dvr.RecordingManager;
    class TestRecord
    //Object of OcapRecordingManager class
    private static OcapRecordingManager recManager = null;
    public static void main(String args[])
    recManager = OcapRecordingManager.getInstance();
    if(recManager == null)
    System.out.println ("Value obtained in OcapRecordingManagerImpl reference is null");
    ------------------ END -------------------
    Thanks!

    Please don't crosspost!
    http://forum.java.sun.com/thread.jspa?threadID=5210277&messageID=9846716#9846716

  • [SOLVED] XSD simpleType trying to assign incompatible types

    Hi all!
    I have a big XSD schema with complex and simple types defined. One of the simple types looks like this (string with min and max length defined):
         <xsd:simpleType name="MySimpleType">
              <xsd:restriction base="xsd:string">
                   <xsd:minLength value="1" />
                   <xsd:maxLength value="36" />
              </xsd:restriction>
         </xsd:simpleType>I assign (copy operation) a string variable to an element of this type. When I compile i get the trying to assign incompatible types warning. I know it's just a warning but I'd like to solve it. I thought I can create a variable of the same type, but I can't (if I try to define message type only the complex type from XSD are displayed).
    Is there a way to get rid of this warning?
    Thanks

    instead of using a variable assignment use the expression builder to construct the 'bpws:getVariableData() equivalent of the variable assignment. The warning will no longer exist.

  • 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?

    Trouble at the end of this code involving incompatible types within word = listEasy.get(wordArrayLocation); along with the other two in that method. Says it needs a java.lang.String.
    import java.util.Random;
    import java.util.Scanner;
    import java.util.ArrayList;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import java.lang.String;
    public class WordArray
       public WordArray() throws FileNotFoundException
          Creation of 3 word arrays based off of the desired level of game difficulty
          ArrayList<String> listEasy = new ArrayList<String>();
          ArrayList<String> listIntermediate = new ArrayList<String>();
          ArrayList<String> listHard = new ArrayList<String>();
          //open the physical files (words*.txt) for use in the corresponding ArrayList
          FileReader readerEasy = new FileReader("wordsEasy.txt");
          FileReader readerIntermediate = new FileReader("wordsIntermediate.txt");
          FileReader readerHard = new FileReader("wordsHard.txt");
          use a Scanner object called "in*" to access the respective file handle.  
          Scanner inEasy = new Scanner(readerEasy);
          Scanner inIntermediate = new Scanner(readerIntermediate);
          Scanner inHard = new Scanner(readerHard);
       Use a loop to walk through the input file WordsEasy.txt reading one line at a time. 
       while (inEasy.hasNext())
          String record = inEasy.next();
          listEasy.add(record);
       Use a loop to walk through the input file WordsIntermediate.txt reading one line at a time. 
       while (inIntermediate.hasNext())
          String record = inIntermediate.next();
          listIntermediate.add(record);
       Use a loop to walk through the input file WordsHard.txt reading one line at a time. 
       while (inHard.hasNext())
          String record = inHard.next();
          listHard.add(record);
       inEasy.close();
       inIntermediate.close();
       inHard.close();
       set ListEasy's size
       public int setListEasySize()
          listEasySize = listEasy.size();
       set ListIntermediate's size
       public int setListIntermediateSize()
          listIntermediateSize = listIntermediate.size();
       set ListHard's size
       public int setListHardSize()
          listHardSize = listHard.size();
       public int setGeneratorLength(int difficultyLevel)
          if (difficultyLevel == 3)
             generatorLength = listHardSize - 1;
          else if(difficultyLevel == 2)
             generatorLength = listIntermediateSize - 1;
          else
             generatorLength = listEasySize - 1;
          Picks a random word
          @return
       public int randWord()
          Random generator = new Random();
          wordArrayLocation = generator.nextInt(generatorLength);
       public String getWord(int difficultyLevel)
          if (difficultyLevel == 3)
             word = listHard.get(wordArrayLocation);
          else if(difficultyLevel == 2)
             word = listIntermediate.get(wordArrayLocation);
          else
             word = listEasy.get(wordArrayLocation);
          return word;
       private String word;
       private int wordArrayLocation;
       private int generatorLength;
       private int listEasySize;
       private int listIntermediateSize;
       private int listHardSize;
       private ArrayList<WordArray> listEasy;  
       private ArrayList<WordArray> listIntermediate;
       private ArrayList<WordArray> listHard;
    }

    Here is what I have changed things to...
    import java.util.Random;
    import java.util.Scanner;
    import java.util.ArrayList;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import java.lang.String;
    public class WordArray
       public WordArray() throws FileNotFoundException
          Creation of 3 word arrays based off of the desired level of game difficulty
          //open the physical files (words*.txt) for use in the corresponding ArrayList
          FileReader readerEasy = new FileReader("wordsEasy.txt");
          FileReader readerIntermediate = new FileReader("wordsIntermediate.txt");
          FileReader readerHard = new FileReader("wordsHard.txt");
          use a Scanner object called "in*" to access the respective file handle.  
          Scanner inEasy = new Scanner(readerEasy);
          Scanner inIntermediate = new Scanner(readerIntermediate);
          Scanner inHard = new Scanner(readerHard);
       Use loops to walk through the input file reading one line at a time. 
          while (inEasy.hasNext())
             String record = inEasy.next();
             listEasy.add(record);
          while (inIntermediate.hasNext())
             String record = inIntermediate.next();
             listIntermediate.add(record);
          while (inHard.hasNext())
             String record = inHard.next();
             listHard.add(record);
       inEasy.close();
       inIntermediate.close();
       inHard.close();
       set the size of of the arraylists to a variable.
       public void setListEasySize()
          listEasySize = listEasy.size();
       public void setListIntermediateSize()
          listIntermediateSize = listIntermediate.size();
       public void setListHardSize()
          listHardSize = listHard.size();
       //Set the difficulty level from user input  
       public void setDifficultyLevel(int difficulty)
          difficultyLevel = difficulty;
       //Calculate the wanted randomm generator length depending on the difficulty level
       public void setGeneratorLength()
          if (difficultyLevel == 3)
             generatorLength = listHardSize - 1;
          else if(difficultyLevel == 2)
             generatorLength = listIntermediateSize - 1;
          else
             generatorLength = listEasySize - 1;
       // Calculates what random arraylist location to pull an object from
       public void randWord()
          Random generator = new Random();
          wordArrayLocation = generator.nextInt(generatorLength);
          Sets the selected arraylist object to another object
       public void setWordObject()
          if (difficultyLevel == 3)
             wordObject = (listHard.get(wordArrayLocation));
          else if(difficultyLevel == 2)
             wordObject = listIntermediate.get(wordArrayLocation);
          else
             wordObject = listEasy.get(wordArrayLocation);
          returns the word
          @return
       public String getWord()
          word = wordObject.toString();
          return word;
       private ArrayList<String> listEasy = new ArrayList<String>();
       private ArrayList<String> listIntermediate = new ArrayList<String>();
       private ArrayList<String> listHard = new ArrayList<String>();
       private String word;
       private Object wordObject;
       private int difficultyLevel;
       private int wordArrayLocation;
       private int generatorLength;
       private int listEasySize;
       private int listIntermediateSize;
       private int listHardSize;
    }Edited by: jojavawuz on Nov 19, 2008 8:34 AM

  • 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

  • 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

  • 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]

Maybe you are looking for

  • Excluding Additional Charges Paid from Party Dues

    Hello There is a requirement where a special charge has been paid during invoicing. this has to be added in invoice or GRN. The amount will not be in the party's account due but should be included in item valuation as cost. To explain in detail - A/P

  • How to make permission to enter Only Digits in String Context Attribute?

    1. It is necessary to allow entry into InputField only digits. 2. The number of digits is limited to 5. There is a context attribute "Code" of type string. I have a code: ISimpleTypeModifiable attributeType = wdContext.nodeCreateParams (). GetNodeInf

  • Error Config tool

    Hi Experts!!! I have a problem, I am doing a Import Enterprise Portal, my problem is that when I open the config tool, it say: the system cannot find the path specified. Program terminated abnormally. My OS is Windows 2008 R2 with java 1.6 and the en

  • Mini Running Slow

    My computer is running very slow lately. Even when zero programs are open it still takes a few seconds to click on an item on the desktop. Is there some type of disk cleanup I can run? Or even anything else? I am running OS 10.5 with 512 MB and an 80

  • IPhone OS 3.0.1: What is new the calendar category 'Calendar' used for?

    In iPhone OS 3.0.1, there is a new MobileMe calendar category, which is purple, called 'Calendar'. It seems to serve the same purpose as the orange 'Unfiled' calendar category. However, Apple iPhone Support and MobileMe Support seem to have no idea w