Can't convert int to java.lang.Integer.

Hi everyone.
I'm working on an auction site at the moment and have problems gaining a bidID number. This is part of my code and my error.
AuctionFacade aHse = (AuctionFacade) application.getAttribute("AuctionFacade");
String strTraderName = (String)session.getAttribute("traderName");
String strPassword = (String)session.getAttribute("password");
String strIDNum = request.getParameter("auctionID");
Integer intID = Integer.valueOf(strIDNum);
Integer [] bids = aHse.getAllBids(intID);
float fltYourBid = aHse.getBidPrice(bids.length);
^
Can't convert int to java.lang.Integer.
can anyone help please?

So, does "aHse.getBidPrice" expect an int or an Integer as its parameter? And does it return an int, or an Integer, or what? The answer to those questions may lead to your solution -- look at what you are actually using as the parameter, for example.

Similar Messages

  • Can't convert int to java.lang.Object

    When I deploy my customer Bean, the following error occures, I think the main problem is Can't convert int to java.lang.Object, does anyone facing the same problem with me?
    <pre>C:\j2sdkee1.3\repository\home\gnrtrTMP\CustomerApp\CustomerBean_RemoteHomeImpl.j
    ava:27: Incompatible type for declaration. Can't convert int to java.lang.Object
    java.lang.Object primaryKey = ejb.ejbCreate(param0, param1, para
    m2);
    ^
    C:\j2sdkee1.3\repository\home\gnrtrTMP\CustomerApp\CustomerBean_RemoteHomeImpl.j
    ava:57: Incompatible type for =. Can't convert int to java.lang.Object.
    primaryKeys = ejb.ejbFindByPrimaryKey( param0);
    ^</pre>
    I really need your help!!!

    you can only convert one object type to another. Integer is an object int isnt. You might want to convert int to Integer and then go ahead.
    see if it works.

  • Cant convert boolean to java.lang.Boolean - HUH?

    I'm fairly new to Java, but I'm pretty sure this should work.
    Can someone tell me why I'm getting these compiler errors:
    wehServlet.java:72: Incompatible type for if. Can't convert java.lang.Boolean to boolean.
    if (checkoutSpecificFile(req,res,busId,tempDir)) {
    ^
    wehServlet.java:123: Incompatible type for return. Can't convert boolean to java.lang.Boolean.
    return true;
    Here's the basic code:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    public class wehServlet extends HttpServlet {
    private void someThing (HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    if(tryThis()) {
    <do something>
    } else {
    <do something else>
    private Boolean tryThis() {
    return false;
    Why can't I do this?
    How do I fix it?
    I tried
    if(tryThis().booleanValue())....
    and I get this compile error:
    Incompatible type for return. Can't convert boolean to java.lang.Boolean
    Now what do I do?

    There's a lot of confusion caused by these "Wrapper" objects, not just Boolean but Integer, Long etc.
    The basic ("primitive") types are lower case names, boolean, int, long etc..
    The related items with capital letters are "wrapper" objects. The are used in a context where you basically want to store a single value but must do so as an Object, for example in aggregate objects like Map or List.
    You should avoid these unless there's a specific reason to use them.
    You can convert between boolean and Boolean, int and Integer etc. but it has to be done explicitly. As far as Java is concerned they're entirely different kind of thing. To java the Boolean class is just another kind of Object, it has no special syntactic significance.
    boolean b;
    Boolean bo;
    b = bo.booleanValue();  // covert from Boolean object to boolean primitive
    bo = new Boolean(b); // convert primitive to Object
    if(bo.booleanValue()) {  // test Boolean objed

  • Required: java.lang.Integer

    This is test.java:
    import java.lang.Integer;
    class Testit {
    Integer ix = (Integer)1;
    This is the result of the javac:
    javac ca\test.java
    ca\test.java:4: inconvertible types
    found : int
    required: java.lang.Integer
    Integer ix = (Integer)1;
    ^
    1 error
    Can anyone explain this?
    Java is mysterious.
    Thanks,
    Grant Head

    This is because 1 is not object in Java. Any integer is primitive type. They are not object. So you cannot cast them into object. If you want to creat Integer object from integer. Simply do following...
    import java.lang.Integer;
    class Testit {
    Integer ix = new Integer(1);
    }However, in C#, everything is object. Any integer, floating points are all object. That's one of difference between Java and C#.
    Hope this help. :)
    mrbabe

  • How to convert from java.lang.Integer to int

    Could you please show me
    how to convert from java.lang.Integer to int?
    and how to convert from java.lang.Integer to String?
    Thanks,
    Minh

    Could you please show me
    how to convert from java.lang.Integer to int?
    and how to convert from java.lang.Integer to String?Tip: always keep a browser open on the API docs; if you've got a
    couple of MBs to spare, download the docs; it's very convenient.
    kind regards,
    Jos

  • ClassCastException for java.lang.Integer in JSF

    Hi,
    I am a newbie, i am working on adding 2 numbers in jsf.
    Where i have a addNumber.jsp:-
    Number1:<h:inputText value"#{AddBean.num1)}"/>
    Number2:<h:inputText value"#{AddBean.num2)}"/>
    <h:commandButton value="Add" action="#{AddBean.sum}"/>
    In AddBean.java
    I have getters and setters for num1 & num2 property whose datatype is int.
    public int sum(){
    System.out.println("Inside sum");
    return (num1+num2);
    Here when i click the Add button the sum() is fired where it is printing "Inside sum" after that i am getting a "ClassCastException saying that java.lang.Integer". Which means i can only use Integer object for calculation rather than using primitive datatype(int)?
    What is the problem here? Pls. do explain?
    Thanks

    The action method should be declared void or return a String. It is to be used for the navigation-case entries in the faces-config.xml. If you want a postback to the same page, just declare it void. It should not return the intented "result" of the action. Store the result somewhere as a bean property.
    The following example should work:<h:form>
        <h:inputText value="#{addBean.number1}" />
        <h:inputText value="#{addBean.number2}" />
        <h:commandButton value="Add" action="#{addBean.sum}" />
        <h:outputText value="#{addBean.result}" />
    </h:form>AddBeanprivate int number1; // + getter + setter
    private int number2; // + getter + setter
    private int result; // + getter only
    public void sum() {
        result = number1 + number2;
    }And I'd rather to use Integer instead of int, but that's more a design choice.

  • Can't convert int to int[]    URGENT!

    HI list!
    Here is the code part I have:
    /** Holds the permutated groups which are arrays of integers. */
    Vector v;
    if(arg.length<3) System.exit (0); //Need at least 3 arguments
    elements=new int[arg.length-1]; //Create array to hold elements
    /* Copy the arguments into the element array. */
    for(i=0;i<arg.length-1;i++) elements=Integer.parseInt(arg[i+1]);
    groupsize=Integer.parseInt(arg[0]); //Get the number in each group.
    calc(groupsize,elements.length); //Find out how many permutations there are.
    v=permutate(groupsize,elements); //Do the permutation
    for(i=0;i<v.size();i++) { //Print out the result
    elements=(int[]) v.get(i);
    System.out.println("");
    for(j=0;j<elements.length;j++) System.out.print(elements
    [j]+" ");
    System.out.println("\nTotal permutations = "+v.size());
    and the error I get is:
    Permutate.java:26: Incompatible type for =. Can't convert int to int[]. for(i=0;i<arg.length-1;i++) elements=Integer.parseInt(arg[i+1]);

    elements=(int[]) v.get(i);
    The above statement is illegal. Its not possible to
    use an array type in casting at all.
    Basically you are trying to do a kind of multiple
    casting, which is not possible.
    You might want to store vectors in vector v instead of
    arrays in vector v. Its better to do this.There's nothing wrong with the line
    elements = (int[]) v.get(i);
    assuming the returned object from the vector is in fact an array of int. Even then, it is a runtime exception condition not a compile-time error.
    Using arrays is perfectly valid where you know the size of the array at creation and do not need to resize it during use... The arrays are fast and compact. This is however not a comment on the approach taken in this case but merely an observation that arrays are not always an inferior choice to one of the collection classes.
    Now put up your dukes... ;)

  • Error message:can't convert int to int[]

    Hi,
    I am trying to build a java code which convert decimal to binary
    but ,I found error message "can not convert int to int[]"
    some line of code:
    int i=12,n=0;
    int arr[n]=i%2;
    n++;
    here I am trying to store remainder in an integer arrary.
    how can i do this???????
    guide me please
    -shobhit singh

    shobhit_onprob wrote:
    i want to store some integer values in to an integer arraryDid you follow the address that was given to you? I doubt it, and even if you did, 2 minutes is not enough time to read, let alone understand, the tutorial.
    Go back there, it describes all the basics you need.

  • Dyna Form +Validator Framework--- peculair problem with java.lang.Integer

    In my struts application , i m using Dyna Action form,and Validator framework
    <form-bean
    name="myDynaForm"
    type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="name" type="java.lang.String"/>
    <form-property name="phoneNo" type="java.lang.Integer"/>
    </form-bean>
    Now if user does not enter name , then a error meassage is dispalyed,
    and aslo this time phoneNo shows 0.
    why 0 is displayed here?
    Can anybody tell me

    Hi all,
    If my memory serves me well, the exception is thrown because the application needs a working calendar for a person provided in time mangement. Make sure the correct infotypes are used. Also the organization structure needs to be set up correctly. The manager needs someone to approve and the employee needs someone to get approved by.
    Regards, Marcel.

  • Integer and java.lang.Integer?

    hi
    I'm using DefaultTableModel method getValueAt which takes 2 integers as parameters
    i have the vector colnumbers which has integers in it. Im trying to get these integers back out again to use in the getValue at method but the compilercomplains that i need int,int nad not int, java.lang.Integer.
    Why are there 2 different integers? and how do i just get it back as int????
    thanks
    Vector unsorted = new Vector();
    for(int j=0; j<colnumbers.size(); j++)
    for(int i=0; i<=max_rows; i++)
         unsorted.add(tm.getValueAt(i,(Integer)colnumbers.elementAt(j)));     
    }

    unsorted.add(
      tm.getValueAt(
        i,
        ((Integer) colnumbers.elementAt( j )).intValue()
    );you just needed to parenthesize to indicate that intValue() gets called on the result of casting colnumbers.elementAt( j ) to type Integer.

  • Java.lang.Integer behaviour

    Hi all,
    While preparing for my SCJP6 i was playing with the java.lang.Integer integer wrapper. I found some behaviour which I could not explain. Below is the code and output on jre6.
    public void test(){
              Integer int1 = 100;
              Integer int2 = 100;
              System.out.println(int1!=int2);
              System.out.println(int1==int2);
              System.out.println(int1.equals(int2));
         }OUTPUT:
    false
    true
    true
         public void test(){
              Integer int1 = 1000;
              Integer int2 = 1000;
              System.out.println(int1!=int2);
              System.out.println(int1==int2);
              System.out.println(int1.equals(int2));
         }OUTPUT:
    true
    false
    true
    As you can see the == and != operators behave differently for values 100 and 1000.
    Please let me know why is it so.
    Thanks.

    Thanks for the post,
    again i'd stress on the fact that I want to be able to determine the behavior of == and != operator regardless of whether i should use them or not.
    Some place i have read that == actually Unboxes the object and compares the values and not the Object ref where as != always compares the obj ref only.
    The behavior i have found is that both operators work on the actual object reference. If the Object value is >-129 and <128 then the JVM uses the same underlying object(cached one) and if the value is out of this range then new object is created.
    So
    Integer i=1000,i2=1000;
    i==i2 OUTPUT false
    i!=i2 OUTPUT true.
    Integer i=100,i2=100;
    i==i2 OUTPUT true
    i!=i2 OUTPUT false.
    I just want a web link where I can confirm my findings.
    Edited by: rishabhchandra on Jun 20, 2009 7:30 PM

  • Java.lang.Integer defaulting to zero

    I am using JAXB for several years, but never dived into details.
    I am not using a schema.
    When I am unmarshalling a XML file, JAXB always defaults my java.lang.Integer attributes to zero instead to null, when the attribute is not given in the XML file.
    How can I change this? I like the Integers to be null, just like in a "normal" Java program.
    Thanks
    Markus

    mkarg wrote:
    When I am unmarshalling a XML file, JAXB always defaults my java.lang.Integer attributes to zero instead to null, when the attribute is not given in the XML file.I am using JAXB 2.1.3 in JDK 1.6. It uses java.math.BigInteger instead of java.lang.Integer for xs:integer types in schema.
    It assigns null when attribute is not given in XML, this is similar to your need.
    Which version of JAXB are you using?

  • Cannot convert type class java.lang.String to class oracle.jbo.domain.Clob

    Cannot convert type class java.lang.String to class oracle.jbo.domain.ClobDomain.
    Using ADF Business Components I have a JSFF page fragment with an ADF form based on a table with has a column of type CLOB. The data is retrieved from the database and displayed correctly but when any field is changed and submitted the above error occurs. I have just used the drag and drop technique to create the ADF form with a submit button, am I missing a step?
    I am using the production release of Jdeveloper11G

    Reproduced and filed bug# 7487124
    The workaround is to add a custom converter class to your ViewController project like this
    package oow2008.view;
    import javax.faces.application.FacesMessage;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    import javax.faces.convert.ConverterException;
    import oracle.jbo.domain.ClobDomain;
    import oracle.jbo.domain.DataCreationException;
    public class ClobConverter implements Converter {
         public Object getAsObject(FacesContext facesContext,
                                   UIComponent uIComponent,
                                   String string) {
           try {
             return string != null ? new ClobDomain(string) : null;
           } catch (DataCreationException dce) {
             dce.setAppendCodes(false);
             FacesMessage fm =
               new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                "Invalid Clob Value",
                                dce.getMessage());
             throw new ConverterException(fm);
         public String getAsString(FacesContext facesContext,
                                   UIComponent uIComponent,
                                   Object object) {
           return object != null ?
                  object.toString() :
                  null;
    }then to register the converter in faces-config.xml like this
    <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee">
      <application>
        <default-render-kit-id>oracle.adf.rich</default-render-kit-id>
      </application>
      <converter>
        <converter-id>clobConverter</converter-id>
        <converter-class>oow2008.view.ClobConverter</converter-class>
      </converter>
    </faces-config>then reference this converter in the field for the ClobDomain value like this
              <af:inputText value="#{bindings.Description.inputValue}"
                            label="#{bindings.Description.hints.label}"
                            required="#{bindings.Description.hints.mandatory}"
                            columns="40"
                            maximumLength="#{bindings.Description.hints.precision}"
                            shortDesc="#{bindings.Description.hints.tooltip}"
                            wrap="soft" rows="10">
                <f:validator binding="#{bindings.Description.validator}"/>
                <f:converter converterId="clobConverter"/>
              </af:inputText>

  • Error: could not be converted to [class java.lang.Class].

    I am newbie to JDeveloper (10.1.2) on winxp and i was trying to setup the example from the following url http://radio.weblogs.com/0129487/2003/09/19.html
    It is a how to on "Executing Toplink Queries using JavaBean DataControl "
    Any help would be greatly appreciated.
    Near the bottom on step "In StrutsPageFlow diagram, select allEmpsDA Data Action, right mouse and chooe Run" i get a the following runtime errors:
    Validation Error
    You must correct the following error(s) before proceeding:
    JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.toplink.exceptions.ConversionException, msg= Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees
    JBO-29000: Unexpected exception caught: oracle.toplink.exceptions.ConversionException, msg= Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees
    Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees

    This error is happening on a read.
    Here is the mapping descriptor:
    <database-mapping>
    <attribute-name>SuppItemCollection</attribute-name>
    <read-only>false</read-only>
    <reference-class>package.SuppItem</reference-class>
    <is-private-owned>false</is-private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <indirection-policy>
    <mapping-indirection-policy>
    <type>oracle.toplink.internal.indirection.NoIndirectionPolicy</type>
    </mapping-indirection-policy>
    </indirection-policy>
    <container-policy>
    <mapping-container-policy>
    <container-class>java.util.Vector</container-class>
    <type>oracle.toplink.internal.queryframework.ListContainerPolicy</type>
    </mapping-container-policy>
    </container-policy>
    <source-key-fields>
    <field>SUPP.REQ_NUM</field>
    </source-key-fields>
    <target-foreign-key-fields>
    <field>SUPP_ITEM.REQ_NUM</field>
    </target-foreign-key-fields>
    <type>oracle.toplink.mappings.OneToManyMapping</type>
    </database-mapping>
    Object model has a Supp class that has a collection of SuppItem(s). I was allowing the Mapping Workbench to create the Java Source. I'm not to fond of that, but I thought it would be easiest to get things going.
    The datamodel is similiar to the class model.
    Thanks for the help,
    Mike

  • Can't convert FileReader to java.io.Reader

    Hi
    I have a code segment that generates error during compilation of the source file: "Incompatible type for constructor. Can't convert FileReader to java.io.Reader.
         buffVideo = new BufferedReader (file)
         ^
    The code segment is:
    FileReader file;
    BufferedReader buffVideo;
    StreamTokenizer tokenVideo;
    String s;
    try {
         file = new FileReader (fileVideo);
         buffVideo = new BufferedReader (file);
         tokenVideo = new StreamTokenizer (buffVideo);
    import java.io.* is at the top of the .java file. It is a part of a definition of a new class. fileVideo is a String variable containing file name of a text file.
    Exactly the same .java source file compiles on a Windows 98 based machine, but not on a Windows 2000 Professional. I use version 1.1.6 as it is required by my current course.
    Can anybody suggest any resoultion for this problem, please?
    Thanks in advance

    Branko,
    Wow, my ID still works. Amazing, I haven't visited for years.
    Ged Byrne writes:
    Branko,
    This is a realy puzzler. My only guess is that you have a namespace
    conflict. The error message states:
    Can't convert File Reader to java.io.Reader
    It seems that there is another class called FileReader that is clashing
    with the on in java.io.
    Have you inadvertantly named something FileReader yourself?
    Perhaps your classpath is including something that contains a FileReader.
    Try declaring file as java.io.FileReader rather than just FileReader.
    I'm clutching at straws.
    Ged.

Maybe you are looking for