MyInteger class- compile error - method doesnt implement comparable method

I am trying to test how the code for a hash table works- I have 4 classes
Hashable interface
QuadraticProbableHashTable
HashEntry
MyInteger
Everything is compiling but one error comes up saying that "Class must implement the inherited abstract method Comparable.compareTo(object)."
I have a comparable method with the same signature as that in Comparable interface; in MyInteger.java where the problem is. However I still have the same problem.
     * Wrapper class for use with generic data structures.
     * Mimics Integer.
    public final class MyInteger implements Comparable, Hashable
         * Construct the MyInteger object with initial value 0.
        public MyInteger( )
            this( 0 );
         * Construct the MyInteger object.
         * @param x the initial value.
        public MyInteger( int x )
            value = x;
         * Gets the stored int value.
         * @return the stored value.
        public int intValue( )
            return value;
         * Implements the toString method.
         * @return the String representation.
        public String toString( )
            return Integer.toString( value );
         * Implements the compareTo method.
         * @param rhs the other MyInteger object.
         * @return 0 if two objects are equal;
         *     less than zero if this object is smaller;
         *     greater than zero if this object is larger.
         * @exception ClassCastException if rhs is not
         *     a MyInteger.
        public int compareTo( Comparable rhs )
            return value < ((MyInteger)rhs).value ? -1 :
                   value == ((MyInteger)rhs).value ? 0 : 1;
         * Implements the equals method.
         * @param rhs the second MyInteger.
         * @return true if the objects are equal, false otherwise.
         * @exception ClassCastException if rhs is not
         *     a MyInteger.
        public boolean equals( Object rhs )
            return rhs != null && value == ((MyInteger)rhs).value;
         * Implements the hash method.
         * @param tableSize the hash table size.
         * @return a number between 0 and tableSize-1.
        public int hash( int tableSize )
            if( value < 0 )
                return -value % tableSize;
            else
                return value % tableSize;
        private int value;
    }

>
You might want to also allow for cases where the
value passed in is null, or the argument to the
method is NOT a MyInteger object :-)
Just a small note - the javadocs for Comparable#compareTo says the following:
Throws:
ClassCastException - if the specified object's type prevents it from being compared to this Object.
So it's perfectly OK to blindly try to cast to the desired type in the sense that you are not violating the Comparable contract if the cast fails.

Similar Messages

  • Problem When Import Java Class -compilation error

    Hi all
    I made a java class that has methods to return Screen width and Height .
    package tarek;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    public class Screen
    Dimension dim ;
    public Screen()
    dim = Toolkit.getDefaultToolkit().getScreenSize();
    public double getWidth()
    double w = dim.getWidth();
    return w;
    public double getHeight()
    double h=dim.getHeight();
    return h;
    I made the jar file " screen.jar" and make it ready to use in form builder
    I opened form builder and make import java class (From program>import java class>choose the class anc click import)
    The class now imported successfully and the PL/SQL package body is:
    PACKAGE Screen /* tarek.Screen */ IS
    -- DO NOT EDIT THIS FILE - it is machine generated!
    -- Constructor for signature ()V
    FUNCTION new RETURN ORA_JAVA.JOBJECT;
    -- Method: getHeight ()D
    FUNCTION getHeight(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER;
    -- Method: getWidth ()D
    FUNCTION getWidth(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER;
    END;
    Now I made a button on the form and i WRITE THIS CODE TO INVOKE THE CLASS on when_button_pressed
    DECLARE
         vScreen_Class ORA_JAVA.JOBJECT;     
    BEGIN
         vScreen_Class := SCREEN.NEW;
    END;
    My problem is I have compilation error
    error 306 AT LINE 5 , COLUMN 25
    wrong number or types of argument in call to "NEW"
    I do not know what is the reason of this compilation error?
    Is it because the method in java return "double datatype" while in oracle return "number datatype"
    Please help
    Edited by: [email protected] on Dec 28, 2009 10:24 AM

    Sarah, I ca not move my thread to JDeveloper because it is not java issue. The problem is with my PL/SQL code and the way I make Import Java class to forms Builder. The Java code is OK.
    Andreas Thank you so much for replying. In fact I made a full compile "Ctrl+Alt+K". but still error
    The following is the package Body
    PACKAGE BODY Screen IS
    -- DO NOT EDIT THIS FILE - it is machine generated!
    args JNI.ARGLIST;
    -- Constructor for signature ()V
    FUNCTION new RETURN ORA_JAVA.JOBJECT IS
    BEGIN
    args := NULL;
    RETURN (JNI.NEW_OBJECT('tarek/Screen', '()V', args));
    END;
    -- Method: getHeight ()D
    FUNCTION getHeight(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER IS
    BEGIN
    args := NULL;
    RETURN JNI.CALL_DOUBLE_METHOD(FALSE, obj, 'tarek/Screen', 'getHeight', '()D', args);
    END;
    -- Method: getWidth ()D
    FUNCTION getWidth(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER IS
    BEGIN
    args := NULL;
    RETURN JNI.CALL_DOUBLE_METHOD(FALSE, obj, 'tarek/Screen', 'getWidth', '()D', args);
    END;
    BEGIN
    NULL;
    END;
    ---------------------------------------------------------------------------------

  • Class Compilation Error in Upgrade

    Hello,
    I have upgraded classes written in 4.6c to ECC 6.0 and receive a compilation error saying:
    'INCLUDE report "Z_CLASS_ NAME========CL" not found'
    Here the name of the public class is "Z_CLASS_NAME".
    Any clues as to how to resolve this error?
    Thanks and regards, Pankaj

    Hello Pankaj
    The report "Z_CLASS_ NAME========CL" is the INCLUDE name of your class. The compilation error may be due to a missing entry in table TMDIR holding all the include names of classes. Also, keep in mind that SAP has changed the organisation of class includes in newer release. For example, on 4.6c you need to write makros within the methods where they were used. On ERP 6.0 we have a separate section for coding makros.
    Can you change you class in SE24? If so then I would recommend to make a few trivial changes (description, adding empty lines in methods and private section containing data definitions) and try to regenerate the class. If this does not work you may check the menus of SE24 for repair options.
    The 2 last resorts would be:
    (1) Copy (or rename) the class -> delete the class -> copy back to Z_CLASS_NAME
    (2) Enter missing entries in TMDIR manually
    Regards
      Uwe

  • Class compilation error

    hi,
    iam having class like this..
    in that i have a piece of code..
    DocumentBuilderFactory factory = null;
    factory. = DocumentBuilderFactory.newInstance();
    iam getting compilation error.
    that identifieer expected..
    iam importing import javax.xml.parsers.DocumentBuilderFactory; package..where its going wrong..
    regards,

    there is a point after factory
    //  factory. = DocumentBuilderFactory.newInstance(); <- you code
    factory = DocumentBuilderFactory.newInstance();

  • Compilation error with RWTValDlist T find() method

    This code used to compile fine with SC 4.x C++ compiler. We are migrating to "Sun WorkShop 6 update 2 C++ 5.3 2001/05/15" and it is now generating the following compilation error:
    ===============================
    cd generic/src; make -f generic.mk
    /opt/SUNWspro/bin/CC -c -PIC -compat -library=rwtools7 -O2 -I. -I. -I../include -I/home/jm/sunos5.8/ib_service_3.4.3/include -I/opt/local/megen/include -I/opt/SUNWspro/WS6U2/include/CC -I../../interface/include -I../include -I. -I/home/jm/sunos5.8/acell_4.1/include -I/opt/local/access/home/include -I/home/jm/sunos5.8/acell_4.1/include/packetcpp -I/home/jm/sunos5.8/acell_4.1/include/ecl -I/home/jm/sunos5.8/acell_4.1/include/gels -I/home/jm/sunos5.8/acell_4.1/src/security/include -I/home/jm/sunos5.8/acell_4.1/include/sequencer -I/home/jm/sunos5.8/acell_4.1/include/gen -I/home/jm/sunos5.8/acell_4.1/include/recipeMgr -I/home/jm/sunos5.8/acell_4.1/include/EFEFeature -I/home/jm/sunos5.8/ib_service_3.4.3/include -I/opt/local/megen/include -I/opt/local/rv/include -I/opt/local/etk/include -I/opt/local/etk/include/tdl -DTCPIP=1 -D__SYSVR4 -DSHOP=1 -D_SOLARIS=1 -I/opt/local/std_comp/include ACEAlarmClock.C
    "ACEAlarmClock.C", line 479: Error: Could not find a match for RWTValDlist<ACEObject*>::find(int(const ACEObject*&,void*), void**, ACEObject*).
    1 Error(s) detected.
    *** Error code 1
    make: Fatal error: Command failed for target `ACEAlarmClock.o'
    ===============================
    The header file in question is:
    #include <rw/tvdlist.h>
    class ACEAlarmClock : public ACEObject
    // The public interface.
    public:
    ACEAlarmClock();
    // Default constructor.
    private:
    static void alarmCallback(void *passAheadRef, ib_alarmid alarmId);
    static RWTValDlist<ACEObject *> AlarmClocks;
    and the source file in question is:
    void
    ACEAlarmClock::alarmCallback(void *passAheadRef, ib_alarmid alarmId)
    ACEObject *object = 0;                        // returned by find()
    if (AlarmClocks.find(findAlarmId, &alarmId, object))
    ACEAlarmClock alarmClock = (ACEAlarmClock )object;
    if (alarmClock)
    AlarmClocks.remove(alarmClock);
    alarmClock->isActive_ = FALSE;
    alarmClock->onAlarm(passAheadRef, alarmId);
    return;
    Any help is highly appreciated. Thanks.
    Cesar Saavedra
    [email protected]

    The C++ Migration Guide that comes with the compiler explains in detail everything you to need to know about migrating from C++ 4.2 to C++ 5.3.
    Use the "-compat" option on every CC command, compiling and linking. Any code that worked with C++ 4.2 will work the same way with C++ 5.3 in compat mode.
    -compat=4 sets language and binary compatibility to that of the 4.x compilers. -compat=5 sets language and binary compatibility to ANSI/ISO standard mode. If the -compat option is not specified, -compat=5 is assumed.
    - Rose

  • Bursting Java Concurrent Program Class Compiling Error

    Hi,
    I am trying to compile the Java Class that Tim has provided in his blog to create the Bursting JCP. I am using R12, so that would be XMLP 5.6.3. As far as I can work out the patch that has been developed for the seeded Bursting JCP is not yet available for R12, so I am trying to create one myself from Tim's examples.
    I do not pretend to be a Java expert, or even pretend to have more than and very very very basic knowledge of it, so I am hoping someone will be able to tell me why I am getting the following error when I try to compile it:
    $ javac XMLPReportBurst.java
    XMLPReportBurst.java:220: cannot find symbol
    symbol : constructor OADocumentProcessor(java.io.InputStream,java.io.InputStream,java.lang.String)
    location: class oracle.apps.xdo.oa.util.OADocumentProcessor
    OADocumentProcessor dp = new OADocumentProcessor(ctlFile,fis,"/home/applmgr/tmp");
    ^
    1 error
    The Java Class that I am using can be seen below, and the error seems to be occurring at line 220:
    package oracle.apps.xdo.oa.cp;
    import java.sql.SQLException;
    import java.sql.Connection;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import oracle.jdbc.driver.OracleResultSet;
    import oracle.jdbc.driver.OraclePreparedStatement;
    import oracle.jdbc.driver.OracleCallableStatement;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.util.NameValueType;
    import oracle.apps.fnd.util.ParameterList;
    import oracle.apps.fnd.cp.request.CpContext;
    import oracle.apps.fnd.cp.request.ReqCompletion;
    import oracle.apps.fnd.cp.request.LogFile;
    import oracle.apps.fnd.cp.request.JavaConcurrentProgram;
    import oracle.apps.fnd.cp.request.RemoteFile;
    import oracle.apps.xdo.XDOException;
    import oracle.apps.xdo.oa.util.OADocumentProcessor;
    import oracle.apps.xdo.batch.BurstingListener;
    import java.util.Properties;
    import java.util.Vector;
    public class XMLPReportBurst implements JavaConcurrentProgram, BurstingListener
    public static final String RCS_ID=
    "$Header: JCP4XMLPublisher.java 115.34 2006/01/09 16:54:58 bgkim noship $";
    public static final boolean RCS_ID_RECORDED =
    VersionInfo.recordClassVersion(RCS_ID, "oracle.apps.xdo.oa.cp");
    // Global Reference to pCpContext
    private CpContext ccntxt;
    private LogFile lfile;
    private boolean debug = false;
    private Connection mJConn;
    public void runProgram(CpContext pCpContext)
    lfile = pCpContext.getLogFile();
    lfile.writeln("XML Report Publisher 5.0",0);
    ccntxt = pCpContext;
    // get the JDBC connection object
    mJConn = pCpContext.getJDBCConnection();
    // get parameter list object from CpContext
    ParameterList lPara = pCpContext.getParameterList();
    // get ReqCompletion object from CpContext
    ReqCompletion lRC = pCpContext.getReqCompletion();
    String Params = null;
    int lrequestId = 0;
    String ltemplatecode = null;
    String lApplShortName = null;
    String lLocale = null;
    String lDebug = "N";
    String lOutFormat = null;
    String tmplLang = null;
    String tmplTerr = null;
    int reqid = pCpContext.getReqDetails().getRequestId();
    // Parse Parameters
    while (lPara.hasMoreElements())
    NameValueType aNVT = lPara.nextParameter();
    Params += aNVT.getName() + ":" + aNVT.getValue();
    if ( aNVT.getName().equals("ReportRequestID") )
    lrequestId = Integer.parseInt(aNVT.getValue());
    else if ( aNVT.getName().equals("DebugFlag") )
    lDebug = aNVT.getValue();
    debug = (lDebug.equals("Y")) ? true : false;
    if (debug)
    lfile.writeln("Request ID: "+reqid ,1);
    lfile.writeln("All Parameters: " + lPara.getString(),1);
    lfile.writeln("Report Req ID: "+ lrequestId,1);
    lfile.writeln("Debug Flag: " + lDebug,1);
    try
    lfile.writeln("Updating request description",0);
    String lSqls = "update FND_CONCURRENT_REQUESTS " +
    "set DESCRIPTION='Bursting ' || " +
    " ( select USER_CONCURRENT_PROGRAM_NAME " +
    " from FND_CONC_REQ_SUMMARY_V " +
    " where request_id= :1 ) " +
    "where request_id = :2 ";
    OracleCallableStatement lStmt2 =
    (OracleCallableStatement)mJConn.prepareCall(lSqls);
    lStmt2.setInt(1,lrequestId);
    lStmt2.setInt(2,reqid);
    lStmt2.execute();
    lStmt2.close();
    mJConn.commit();
    if (debug) lfile.writeln("Updated description",0);
    /* Obtain Input xml file from RemoteFile object by lrequestId */
    lfile.writeln("Retrieving XML request information",0);
    lSqls = "select OUTFILE_NODE_NAME, OUTFILE_NAME from " +
    "FND_CONCURRENT_REQUESTS " +
    "where request_id= :1";
    OraclePreparedStatement lStmt1 =
    (OraclePreparedStatement)mJConn.prepareStatement(lSqls);
    lStmt1.setInt(1,lrequestId);
    OracleResultSet lRslt = (OracleResultSet)lStmt1.executeQuery();
    lRslt.next();
    String cNode=lRslt.getString(1);
    String outf=lRslt.getString(2);
    lRslt.close();
    lStmt1.close();
    if (debug) lfile.writeln("Node Name:" + cNode,1);
    lfile.writeln("Preparing parameters",0);
    // PDF output file (Outfile of this request)
    String outputfilename = pCpContext.getOutFile().getFileName();
    if (debug) lfile.writeln(lOutFormat+" output =" + outputfilename, 1);
    OutputStream fout = new FileOutputStream(outputfilename);
    RemoteFile rf = new RemoteFile (pCpContext, cNode, outf, "TEXT");
    String inputfilename = rf.getFile().getAbsolutePath();
    if (debug) lfile.writeln("inputfilename =" + inputfilename, 1);
    if ( inputfilename == null || inputfilename.equals("") )
    lRC.setCompletion(ReqCompletion.ERROR,
    "Error has occured. Please check the log file");
    // Input stream from XML data file ( Outfile of XML generating request)
    InputStream fis = new FileInputStream(inputfilename);
    InputStream ctlFile = new FileInputStream("\\home\\applmgr\\InvoiceBatchBurst.xml");
    lfile.writeln("Starting burst ...",1);
    OADocumentProcessor dp = new OADocumentProcessor(ctlFile,fis,"/home/applmgr/tmp");
    lfile.writeln("Bursting initiated ... ",1);
    dp.registerListener(this);
    lfile.writeln("Listener created ...",1);
    Properties prop= new Properties();
    lfile.writeln("Properties set ...",1);
    prop.put("user-variable:EMAILP","[email protected]");
    dp.setConfig(prop);
    lfile.writeln("Config set ...",1);
    dp.process();
    lfile.writeln("Bursting complete",1);
    fis.close();
    fout.close();
    lRC.setCompletion(ReqCompletion.NORMAL, "Request Completed Normal");
    catch (SQLException e)
    lfile.writeln("--SQLException",1);
    //lfile.writeln(e.getMessage(),1);
    lfile.writeln(getErrorStack(e),1);
    lRC.setCompletion(ReqCompletion.ERROR, e.getMessage());
    catch (XDOException e)
    lfile.writeln("--XDOException",1);
    //lfile.writeln(e.getMessage(),1);
    //lfile.writeln(sw.toString(),1);
    lfile.writeln(getErrorStack(e),1);
    lRC.setCompletion(ReqCompletion.ERROR, e.getMessage());
    catch (Exception e)
    lfile.writeln("--Exception",1);
    lfile.writeln(e.getMessage(),1);
    lfile.writeln(getErrorStack(e),1);
    lRC.setCompletion(ReqCompletion.ERROR, e.getMessage());
    finally
    pCpContext.releaseJDBCConnection();
    private String getErrorStack(Exception exc) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    try
    exc.printStackTrace(pw);
    pw.flush();
    pw.close();
    sw.close();
    return sw.toString();
    catch (Exception e)
    return null;
    public void beforeProcess(){
    if (debug) lfile.writeln("==============Start of Bursting Process=================",0);
    public void afterProcess()
    if (debug) lfile.writeln("==============End of Bursting Process=================",0);
    public void beforeProcessRequest(int requestIndex)
    if (debug)
    lfile.writeln(" ========Start of Process Request",0);
    lfile.writeln(" Request Index +requestIndex",0);
    public void afterProcessRequest(int requestIndex)
    if (debug) lfile.writeln(" ========End of Process Request",0);
    public void beforeProcessDocument(int requestIndex,int documentIndex)
    if (debug){
    lfile.writeln(" ========Start of Process Document",0);
    lfile.writeln(" Request Index "+requestIndex,0);
    lfile.writeln(" Document Index " +documentIndex,0);
    public void afterProcessDocument(int requestIndex,int documentIndex,Vector documentOutputs)
    if (debug){
    lfile.writeln(" ========End of Process Document",0);
    lfile.writeln(" Outputs :"+documentOutputs,0);
    public void beforeDocumentDelivery(int requestIndex,int documentIndex,String deliveryId)
    if (debug){
    lfile.writeln(" ========Start of Delivery",0);
    lfile.writeln(" Request Index "+requestIndex,0);
    lfile.writeln(" Document Index " +documentIndex,0);
    lfile.writeln(" DeliveryId " +deliveryId,0);
    public void afterDocumentDelivery(int requestIndex,int documentIndex,String deliveryId,Object deliveryObject,Vector attachments)
    if (debug){
    lfile.writeln(" ========End of Delivery",0);
    lfile.writeln(" Attachments : "+attachments,0);
    I hope you can help me as this is an on going issue for me that I need to try and get resolved.
    I look forward to hearing any suggestions.
    Regards,
    Cj

    Hi,
    Yes you have one more field in the Data Definition tab that reads Bursting Control File just after the 3 you mentioned .You can upload the control file here.
    However both this functionality and the Bursting Concurrent Program will be available once you have applied the patch for 5.6.3..
    I've been looking too for anyone who has a writeup on the the way this Program can be used.As of now I am just following the Read Me available with this Patch.
    It has some samples...
    Let me know if this helps.
    Regards,
    Lavina

  • J developer class compile error in Jdev 11.1.1.1

    We developed a fusion web projects.
    Sometimes some classes in classpath of projects not included inside of EAR file when we create a deployment profile .
    Then we need to make all, built all.
    Class is added EAR file.
    it seem like a bug. We weren't face this issue in previous versdion of Jdev 11.1.1.0.1

    Yes. We see.
    But we can't describe when the the problem occurs exactly.
    The problem occurs rondomly.
    We deploy the projects. class is missing error occcurs. Then We redoploy problem dissapper.
    I thing problem about to compile dependecy projects.
    Because this class belong to dependent projects. (sometimes even standart model projects files missing.)

  • EJB Compile Error

    Hello,
    I have the following EJB code, and received a compile error at the Salary create() method. I compiled these modules in the following sequence SalaryHome, SalaryEJB, Salary. All .java files located under directory simpleBean. Could anyone shed lights on what I've done wrong? Thanks in advance.
    //=============
    package simpleBean;
    public interface Salary extends javax.ejb.EJBObject
    double calculateSalary (int annualSalary, int pensionContrib, double bonus)
    throws java.rmi.RemoteException;
    //==================
    package simpleBean;
    public interface SalaryHome extends javax.ejb.EJBHome
    Salary create () throws java.rmi.RemoteException,
    ^can not resolve symbol
    javax.ejb.CreateException;
    //===================
    package simpleBean;
    import javax.ejb.*;
    public class SalaryEJB implements SessionBean
    public void ejbCreate() {}
    public void ejbRemove() {}
    public void ejbActivate() {}
    public void ejbPassivate() {}
    public void setSessionContext (SessionContext ctx) {}
    private static double taxRate = 28;
    public double calculateSalary (int annualSalary, int pensionContrib, double bonus)
    double monthly = 0;
    monthly = annualSalary / 12;
    // add bonus
    monthly = monthly + bonus;
    // remove pension contribution
    monthly = monthly - (monthly * (pensionContrib / 100) );
    //remove tax
    monthly = monthly - (monthly * (taxRate / 100) );
    return monthly;
    //======================

    Hi,
    U have to also use the import statement for accessing the Salary.class file in other java files.
    use import simpleBean.*; just after the package simpleBean; statement
    in all other java files : extending EJBHome, implementing SessionBean and the client java file too.
    Hope this helps,
    Seetesh

  • Compilation error while calling static method from another class

    Hi,
    I am new to Java Programming. I have written two class files Dummy1 and Dummy2.java in the same package Test.
    In Dummy1.java I have declared a static final variable and a static method as you can see it below.
    package Test;
    import java.io.*;
    public class Dummy1
    public static final int var1= 10;
    public static int varDisp(int var2)
    return(var1+var2);
    This is program is compiling fine.
    I have called the static method varDisp from the class Dummy2 and it is as follows
    package Test;
    import java.io.*;
    public class Dummy2
    public int var3=15;
    public int test=0;
    test+=Dummy1.varDisp(var3);
    and when i compile Dummy2.java, there is a compilation error <identifier > expected.
    Please help me in this program.

    public class Dummy2
    public int var3=15;
    public int test=0;
    test+=Dummy1.varDisp(var3);
    }test+=Dummy1.varDisplay(var3);
    must be in a method, it cannot just be out somewhere in the class!

  • Compile-time warning during javac of a Class that implements Comparable

    Hello All,
    I have defined a class as follows;
    public class CardTiles extends JButton implements Comparable{
    During normal compilation with javac, it tell me to use Xlint to compile and the warning it throws is below:
    CardTiles.java:4: warning: [serial] serializable class CardTiles has no definition of serialVersionUID
    public class CardTiles extends JButton implements Comparable{
    ^
    1 warning
    What does this warning mean?
    Many thanks!

    ejp wrote:
    you can choose to to differentiate between various versions of your CardTiles classThat's back to front. Serialization will always do that unless you stop it, which you can do via a fixed serialVersionUID. This tells Serialization that different versions of your class are compatible under serialization.I suppose I see it this way because I wouldn't have a serializable object without an ID. Without having an explicit ID the process isn't as transparent to me. It's the same sort of thing as using braces for statements when they're not necessary, e.g.
              if(check)
                   System.out.println("check is on");
              else
                   System.out.println("check is off");     versus     
              if(check) {
                   System.out.println("check is on");
              } else {
                   System.out.println("check is off");
              }

  • Error When Trying to POST: Method not implemented in data provider class

    Hi Experts,
    I have created an Odata Service using Netweaver Gateway Service builder. I am using Advanced Rest Client to test the service. I can successfully GET my data, but I run into issues when I try and POST new data.
    When trying to POST, I used the GET method to get the x-csrf-token, and added it to my header. I also updated the body XML with the data that I would like to POST. However, after sending the POST request, I am getting a "500 Internal Service Error" with the xml message "Method '<OdataServiceName>'_CREATE_ENTITY" not implemented in data provider class".
    Any help on this would be greatly appreciated. Thanks!

    Hi Kelly,
    Can you share screenshots of the error? Maybe something wrong with payload :can you share the same also? Did you try to debug it by putting a breakpoint in the CREATE_ENTITY method in the backend? Any luck?
    Regards,
    JK

  • Error "You may only define methods within "CLASS class IMPLEMENTATION"

    We have code in LMIGOSMC so that the vendor batch number appears in the MIGO transaction for certain movement types.  We have created another, custom movement type in which this functionality should be available so I need to add it to LMIGOSMC.  When I go in and try to make the modification I am getting the following error:
    "You may only define methods within "CLASS class IMPLEMENTATION ...ENDCLASS".
    What am I doing wrong?

    Hi,
    You are not doing anything wrong with regard to the syntax error you are getting.  During the syntax check of include program LMIGOSMC, the system is not aware of the CLASS... ENDCLASS statements within the program LMIGOSM4.  Try the syntax check at the LMIGOSM4 program level (or even better, at the SAPLMIGO level) and you will see that the error is not given.
    Regards,
    Jamie

  • Implementing Comparable in an abstract class

    Hi all,
    I am making my first sortie with abstract classes. I have had a good look around, but would still appreciate some advice with the following problem.
    In my application I have several classes that have many things in common. I have concluded therefore, that if I create and then inherit from an abstract super class, I can reduce and improve my code. I created this abstract class:
    public abstract class YAbstractObject implements Comparable {
        public YAbstractObject(int projectId, YObject object, String objectName) {
            this.projectId = projectId; // Always the same parameters
            this.object = object;
            this.objectName = objectName;
        // This is abstract as it must always be present for sub classes but differant processing will take place
        public abstract void resolveObject();
        // These three methods will always be the same for all sub classes
        public String getName() {
            return objectName;
        public YObject getObject() {
            return object;
        public boolean isValid() {
            return isValid;
    // Overridden and always the same for all sub classes
        public String toString() {
            return objectName;
        // implemented abstract method
        public int compareTo(Object thatObject) {
            // Issue here! I would like something as follows:
            //  return this.getName().compareToIgnoreCase(thatObject.getName());
    // Variable decleration
        private int projectId;
        private YObject object;
        private String objectName;
        private boolean isValid;As I have commented in the compareTo() method, I would like it to be able to use the getName() method for comparison objects and compare them. But it does not like this, as it does not know that "thatObject" is of the same class as this object - I hope that made sense.
    in essence, I want to inherit this method for different classes and have it work with each.
    Is there a way to do this? Generics?
    Any observations, greatly appreciated,
    Steve

    You can use also generics (if applicable: java -version >= 1.5).
    public abstract class Test implements Comparable<Test> {
         String name;
         public Test(String name) {
              this.name = name;
         public String getName() {
              return name;
         public int compareTo(Test obj) {
              return this.getName().compareTo(obj.getName());
    public class Other extends Test {
         public Other(String name) {
              super(name);
    public class Tester extends Test {
         public Tester(String name) {
              super(name);
         public static void main(String[] args) {
              Test t = new Tester("t");
              Test a = new Tester("a");
              Test o = new Other("t");
              System.out.println(t.compareTo(a));
              System.out.println(t.compareTo(new Object())); //compile error
              System.out.println(t.compareTo(o));
    }Without the compile error line it will give the following result:
    19
    0

  • Abstract Class that implements Comparable

    I am trying to understand how a comparable interface works with an abstract class. Any help is greatly appreciated.
    I have a class ClassA defined as follows:
    public abstract class ClassA implements Comparable I have a method, compareTo(..), within ClassA as follows:
    public int compareTo(Object o) I have a sub-class ClassB defined as follows:
    public class ClassB extends ClassAI am receiving a compile error:
    Class must implement the inherited abstract method packagename.ClassA.compareTo(Object)
    Should or can the compareTo be abstract in ClassA and executed in ClassB? Just not sure how this works.

    ???? if you are inheriting from an abstract class your subclass must implement methods that were declared in the parent (abstract) class but not implemented
    When in doubt, refer to the Java Language Specification..

  • Compiler error  type of object in for (Class obj : Items) - why?

    Hi all,
    I'm new to Java generics and am in the process of converting some
    legacy code. I have encountered a particular error which I do not
    understand the reason for, since I think the compiler has enough
    information about the code to work out type information. The following
    code shows a test class which demonstrates this error:
    import java.util.Collection;
    public class Test
        interface Base {}
        static class Impl1 implements Base{}
        public <T extends Base> Collection<T> getCollection(Class<? extends Base> cls)
            return null;
        void someMethod()
            for ( Impl1 obj : getCollection( Impl1.class ))
                // *** compiler complains about the line above ***
                // compiler says:
                // Test.java:22: incompatible types
                // found   : Test.Base
                // required: Test.Impl1
                //        for ( Impl1 obj : getCollection( Impl1.class ))
                //                                        ^
        void someMethod2()
            Collection<Impl1> coln = getCollection(Impl1.class);
            for (Impl1 obj : coln)
                // do something here with obj
    }Why should the compiler complain where it does ( the line marked with
    asterisks) in someMethod, but does not reject the declaration statement
    in someMethod2? I would have assumed both are the same and the
    compiler has the same type information at its disposal to determine
    the correct type.
    Cheers,
    Bonny

    The Java 5 compiler not only looks at a method's name and arguments, but also at its return value in order to determine whether a method is callable and what type should be infered for its type parameters.
    In your example the type parameter T is only used in the declaration of the method's return type. Note that there is no relation between T and the type of the argument cls!
    Thus, the compiles needs to know what type of variable the return value will be assigned to.
    Hence, someMethod2 can be resolved, whereas in someMethod there is no assignment of the return value. (Rather, an implicit call to Iterable.iterator()).
    You can solve this problem by forming a relation between the method's argument, its return type and its type parameter. Just declare the method like this:
    public <T extends Base> Collection<T> getCollection(Class<T> cls)
            return null;
        }

Maybe you are looking for

  • JDBC adapter can't find the jdbc driver class

    Hello, my jdbc driver give an very strange error 11:46:13 (4207): JDBC adapter terminated Mon Aug 02 11:46:13 CEST 2004 ***** 11:46:13 (4210): ERROR: Attempt to load JDBC driver failed ("java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriv

  • Write to Citadel database from LabVIEW?

    Hi. I'm a newbie when it comes to Lookout and the Citadel database... so here's my question for you all: We have various labview applications that log data from instruments. We would like to be able to take this data and store it as "tags" in a Citad

  • Screen exit in QM01 tcode

    Hi all, My requirement is to add a customized screen in QM01 transaction. That is, when the user enters the notification type and press enter, second screen appears. In that 2nd screen (Header data), the user will enter the material number under the

  • IOS SLB and IBM Workload Manager

    Does anyone know if IOS SLB can function similar to Multinode Load Balancing (MNLB) in that the IOS router acts as a Services Manager which contacts the OS390 Worload Manager (WLM) who then reports back the best OS390 server for a particular connecti

  • Photos edited in external editor are huge..

    If I edit a photo in an external editor (Photoshop CS5), the file is saved as an PSD file. This one is about 50 times bigger than the original. Is it possible to convert the file to a JPG after editing so it will use less disk space?