Clone() method error

When I compile the following program I get the "incompatible types error". Are not s1 and s2 of class Object?!
public class CloneApp {
     public static void main(String args[]) {
          CloneApp s1, s2;
          s1 = new CloneApp();
          s2 = s1.clone();
Thanks.

Furthermore, clone() throws an exception if the object's class does not implement Cloneable. Your code should look like
public class CloneApp implements Cloneable {
   public Object clone() {
      try {
         return super.clone();
      } catch(CloneNotSupportedException e) {
         throw new InternalError(e.toString());
   public static void main(String[] args) {
      CloneApp s1, s2;
      s1 = new CloneApp();
      s2 = (CloneApp) s1.clone();
}

Similar Messages

  • Cannot use clone() method of LinkedList...That's strange

    I got a very strange problem. I wrote the following statement:
    Integer[] nums = generateRandomIntegerArray();
    List<Integer> list = new LinkedList<Integer>(Arrays.asList(nums));
    List<Integer> clone = list.clone();
    .....I got an error statement: cannot find symbol-method clone().
    When I use other methods it's fine, but I cannot use clone().
    That's really strange. I've checked many times, clone() method does exist
    in the LinkedList class.

    Your list variaiable is to an object implementing the interface List and clone is not part of the List interface. To get to the clone method you must cast it back to LinkedList, or use a LinkedList reference.

  • No such method error when launching the Interactive form

    Hi Experts,
    I have developed a simeple Java Webdynpro application and added an Interactive form without any controls in it. Created the context with one value node and a binary value attribute.
    I have assigned  value node to datasource and binary attribute to pdfSource. When I launch the application I am getting the following no such method error.
    java.lang.NoSuchMethodError: com/sap/tc/webdynpro/clientserver/uielib/adobe/api/IWDInteractiveForm.setTemplateSource(Ljava/lang/String;)V
    The currently executed application, or one of the components it depends on, has been compiled against class file versions that are different from the ones that are available at runtime.
    If the exception message indicates, that the modified class is part of the Web Dynpro Runtime (package com.sap.tc.webdynpro.*) then the running Web Dynpro Runtime is of a version that is not compatible with the Web Dynpro Designtime (Developer Studio or Component Build Server) which has been used to build + compile the application.
    My NWDS is of Version 7.0.06
    and J2EE Engine is of Version 6.40.
    any guess why I am getting this error.
    Thanks
    Chinna.

    Issue solved. Compatablility issue NWDS 2.0 Version should use for NW 2004.

  • Abstract Method Error and XML Parsing

    I am using wl6sp1. I am parsing an XML file from within the
    servlet using jaxp1.1 and crimson.
    Following is code:
    1- SAXParserFactory spf = SAXParserFactory.newInstance();
    2- sp = spf.newSAXParser();
    3- xr = sp.getXMLReader();
    4- xr.setContentHandler(new ParseXML());
    5- xr.parse( new InputSource("Example3.xml"));
    This program works fine when execute from command line but in servlet on line
    3 it says:
    "Abstract Method Error"
    I have created XML Registry to use Crimson as XML parser rather than default.
    I think somehow wl is still using jaxp1.0 which is built in
    support in wlsp1.
    Whats wrong with the code...or what configuration i am missing???

    I'm assuming you have already put crimson.jar first in the classpath for the java
    command you use to start WebLogic. If so, have you tried putting the servlet in
    a .war file with the crimson.jar in its' WEB-INF/lib directory?
    Regards,
    Mike Wooten
    "anyz" <[email protected]> wrote:
    >
    I am using wl6sp1. I am parsing an XML file from within the
    servlet using jaxp1.1 and crimson.
    Following is code:
    1- SAXParserFactory spf = SAXParserFactory.newInstance();
    2- sp = spf.newSAXParser();
    3- xr = sp.getXMLReader();
    4- xr.setContentHandler(new ParseXML());
    5- xr.parse( new InputSource("Example3.xml"));
    This program works fine when execute from command line but in servlet
    on line
    3 it says:
    "Abstract Method Error"
    I have created XML Registry to use Crimson as XML parser rather than
    default.
    I think somehow wl is still using jaxp1.0 which is built in
    support in wlsp1.
    Whats wrong with the code...or what configuration i am missing???

  • Abstract Method Error in retrieving Blob

    Hi!
    while (rs.next())
    Blob blob=rs.getBlob(1);
    throws Abstract Method Error
    why?
    Thanxs in advance

    You'll probably find that the JDBC driver that you are using doesn't support blobs. Check the documentation that comes with your driver, it should tell you what parts of the JDBC specification it supports.
    Col

  • Server error: Class: UCF Acroform Method error Message: Could not send mess

    Hi Gurus,
    I'm having a problem with displaying PDF file in the portal. I tried reinstalling Adobe 9. Tick and untick the option Display PDF in browser. But still encountering the error. Is it something to do with IE version? Please Help. Thanks in advance.
    Server error: Class: UCF Acroform Method error Message: Could not send message

    Hi,
        Please speify the system information so that I can help you
    Regards
    Sharanya.R

  • HTTP GET method error

    I've created a simple web page that contains a text box in which the user enters an URL. And also have a servlet to take this address and do something "useful" with it. The Servlet has a doPost method to get this address, and the web page also has the corresponding method
    (<FORM method="POST" ACTION="../fyp/AddressServlet" >).
    I'm using a j2ee server, which runs fine, as does the deploytool.
    However, when I attempt to open the web page in my browser, I get the following error,
    "HTTP Status 405-HTTP method GET is not supported by this URL"
    I don't know why I'm getting a GET method error, when it's a POST method I'm using.
    Any help would be appreciated,
    thanks,
    ahhfor

    Hi !
    You're using the POST method to call the servlet when you submit the HTML page. However, when you try to load your HTML page into the browser, this is done with GET !
    Check your server.xml file in the /conf directory and see if your application context is correctly defined. And then check the web.xml file in your application's WEB-INF directory. Finally, check your path to the servlet in your HTML file.

  • When do we override our own clone method not the Object class clone method

    Hi,
    I have a confusion in overriding clone method.We can create clone object by writing Object.clone() but some times I have seen writing our own clone method ,when do we write this,also clone() is defined protected and when we write our own clone it is said to write it public,why?
    Thanks
    Sumit

    protected methods can only be called in the same class and it subclass. You can make clone protected if this is all you need.
    However if you need to clone() the object from another class, it need to be public.
    This is the same for any method.
    Also as Object.clone() is protected you cannot make it private or package-local (this is true of any protected method)

  • Use VB Set keyword with Clone method?

    I am using the TestStand API with Visual Basic 6.0 SP5. Is is necessary to use the Set keyword when calling the Clone method of a PropertyObject? i.e. which is correct:
    Set thePropObj = existingPropObj.Clone("", 0)
    or
    thePropObj = existingPropObj.Clone("", 0)
    Seems the Set keyword would be required, but I am
    running into funny problems with this. I have a step
    that I am trying to create a copy of. (The step contains a call to a LabVIEW VI.) If I omit the Set keyword, execution hangs at the call to Clone. If I include the Set keyword, all information present in the original PropertyObject doesn't seem to get copied to the new one. (Also, oddly enough, if I omit the set keyword, and the step calls a CVI function, everything seems to work
    fine!)
    Anyone have any advice?
    Thanks in advance
    D. LaFosse

    Hello LaFosse,
    You need to use the Set keyword before the clone method statement. However, I have a couple of comments about the code you sent.
    This is the code you sent:
    ' Start up the testStand engine
    Dim theTS As TS.Engine
    Set theTS = New TS.Engine
    ' OK, load in the sequence file I
    ' created. This sequence file
    ' contains nothing more than a call
    ' to a VI in the main stepgroup of
    ' the MainSequence.
    Dim seqFile As SequenceFile
    Set seqFile =
    theTS.GetSequenceFile()
    ' get a handle to the MainSequence
    Dim seq As Sequence
    Set seq = seqFile.GetSequenceByName
    ("MainSequence")
    ' Get a handle to the step that calls
    ' the VI, and a property object for
    ' the step
    Dim theStep As Step
    Set theStep =
    seq.GetStep(0, StepGroup_Main)
    Dim theStepProp As PropertyObject
    Set theStepProp =
    theStep.AsPropertyObject
    ' Create another step. We will attempt
    ' to use Clone to fill in the
    ' properties of this step.
    Dim theOtherStep As Step
    Dim theOtherStepProp As PropertyObject
    Set theOtherStep = theTS.NewStep("",
    TS.StepType_Action)
    Set theOtherStepProp =
    theOtherStep.AsPropertyObject
    ' Call clone...this step will hang.
    theOtherStepProp =
    theStepProp.Clone("", 0)
    Basically the problem is that you are not loading the TypePallete after creating the engine. You shoud include right after the Set theTS = New TS.Engine:
    theTS.LoadTypePaletteFiles
    This should avoid the crash.
    Some Additional comments:
    1. With VB you don't need to create property objects from other objects. All the classes, except the Engine Class, inherit from the Property Object Class. The following Code does the same thing, but without creating propertyobjects directly:
    Sub MySub()
    'Variable Declaration
    Dim theTS As TS.Engine
    Dim seqFile As SequenceFile
    Dim seq As Sequence
    Dim theStep As Step
    Dim theOtherStep As Step
    'Create the Engine
    Set theTS = New TS.Engine
    'Load the Types
    theTS.LoadTypePaletteFiles
    'Get Sequence File
    Set seqFile = theTS.GetSequenceFile()
    'Get Sequence
    Set seq = seqFile.GetSequenceByName("MainSequence")
    'Get Step
    Set theStep = seq.GetStep(0, StepGroup_Main)
    'Clone the Step
    Set theOtherStep = theStep.Clone("", 0)
    'Using the inheritance functionality
    'gets the Step Status
    'Notice that theOtherStep is not a PropertyObject
    'and you can use all the properties and methods that
    'applies to the PropertyObject Class to a Step class
    'in this example
    'Also, in VB when you are typing the statement, you
    'will not see the PropertyObject Class properties and
    'and Methods automatically if the variable is not a
    'PropertyObject type. However, you can still use them
    'as mentioned before
    MsgBox (theOtherStep.GetValString("Result.Status", 0))
    End Sub
    2. When you create or modify sequence files programatically be carefull not to break the license Agreement. You need the development lisence when modifying sequences.
    3. This piece of code is not completed, and you will need to shutdown the engine by the end.
    4. Since you are not handling UI Messages, you will need to be carefull when loading sequences that have the SequenceFileLoad Callback. The engine posts UI Messages when executing this callback. Also when you shutdown the engine, UI Messages are posted. For both operations (Load Sequence and Shuutdown) you may prevent the engine from posting the message (You may check the options parameter for this two methods in TS Programmer Help.)
    5. If you want to run a sequence, again you will need to incorporate in your code the UIMessage Handler part. (You may check the TS Programmer Help->Writing an Application Using the API->UI Messages). Otherwise it may hang since the engine posts UI Messages eventually.
    Regards,
    Roberto Piacentini
    National Instruments
    Applications Engineer
    www.ni.com/support

  • On compilation in J2ME WTK, Midlet code generates clone() method

    I did try to compile a MIDlet which creates a user defined object in J2ME WTK. The compiled code has Object.clone() method invocation. However clone() method is not available in J2ME CLDC API. So the code results in java.lang.NoSuchMethodError and subsequently the emulator crashes. Any idea how to compile the MIDlet so that clone() method is not put in the compiled code ?
    regards,
    Ashwath

    I did include few J2SE classes, which contained clone() method. I removed them, now problem solved.

  • XmlBean usage and the clone() method.

    I'm trying to use the XmlBean class as the superclass for all our business objects and we have an issue with the usage of the clone method.
    Basically our business objects all throw the CloneNotSupportedException (as per Object.clone() signature) while XmlBean.clone() does not throw it. Introducing XmlBean into the hierarchy will cause quite a bit of effort to change clone() signatures for a lot of classes. So, we were wondering if there is any alternative to subclassing XmlBean while at the same time using the efficient caching that it gives us. I guess I'm looking for a "composition" approach rathe than an "inheritance" approach that might work.
    Has anyone faced this issue and is there any other workaround?
    Thanks,
    --Das                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    The reason that I asked is that the exception is "old baggage" from a design flaw in the original JDK 1.0 .. it is a checked exception that can never happen on an object that implements Cloneable, so if you don't throw it, and you implement Cloneable, then it won't be thrown on clone().
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Coherence: Shared Memories for J2EE Clusters

  • Organization Payment method Error

    Dear All,
    When I trying to attach a bank account in cash management Tab im getting following error.
    APP-PAY-34070:the bank account does not uniquely map to cash management account
    If anybody faced similar issue please let me know the solution you have implemented.
    Regards,
    Jithin dev

    962274 wrote:
    Dear All,
    When I trying to attach a bank account in cash management Tab im getting following error.
    APP-PAY-34070:the bank account does not uniquely map to cash management account
    If anybody faced similar issue please let me know the solution you have implemented.
    Regards,
    Jithin devPlease see these docs.
    Defining Organizational Payment Method, Errors: APP-PAY-34070: The Bank Account Does not Uniquely map to Cash Management Account. [ID 1106723.1]
    Costing of Payment : Can We Populate Control Account With Multiple Liability Accounts ? [ID 1266020.1]
    Thanks,
    Hussein

  • I need  to implement clone method  in theAdvancedDataGrid class

    I need  to implement clone method  in theAdvancedDataGrid class, to copy the object in its completeness   Could anyone give me a helping hand.

    Hi Nikos,
    from youe question it's not clear what do you need to copy: data, parts of ADG (GUI) or something else?
    If it's not a GUI - only data - you can use mx.utils.ObjectUtil.copy(value:Object):Object

  • Why doesn't reflection reveal the clone() method in arrays?

    I was surprised to discover that the following code does not reveal the method "clone()", even though you can call "clone()" on an Object[]. Can anyone explain why this is? I was hoping to use the Reflect API to clone an arbitrary object if it was Cloneable, and to throw an Exception otherwise. How can I do this?
    import java.lang.reflect.Method;
    public class Test {
         public static void main(String[] args) throws Exception {
              Object x;
              //pick a class
              x = new Object[] {};
              //is it Cloneable?
              System.out.print("The class " + x.getClass().getCanonicalName() + " is ");
              if(!(x instanceof Cloneable)) System.out.print("NOT ");
              System.out.println("Cloneable");
              System.out.println("-------");
              //what methods are available?
              Method[] meths = x.getClass().getMethods();
              for(Method m : meths) {
                   System.out.println(m.getName());
              System.out.println("-------");
    }

    Just to clarify. I know that clone() is protected in Object, but it is certainly a public method in array objects such as int[], float[], Object[] etc. Test: call clone() on any of these objects! Also, I realize that Cloneable does not itself guarantee the method clone(). Nevertheless, if you take a regular Cloneable object, such as a String, then typically, if you ran myObject.getClass().getMethods() on that object, you'd find the method clone() in the resulting list. i.e., that Class has overwritten Object's protected clone() method with a public clone() method. So since int[], float[] and all the rest have a clearly public clone() method, then why doesn't myFloatArray.getClass().getMethods() show me a method called "clone"? I guess it would have to have something to do with the fact that arrays are funny kinds of classes that are not properly handled by the Reflection API, but is it on purpose that clone() isn't available?

  • What time should I use clone method?

    Hi everyone:
    There is a problem puzzled me all the time. You know,If I want to use a object I could use the code:
    Class A=new Class(); I get a object A so I can use it. But there is a method called "clone".It's function is copy a object.But Why jdk have this method.Is there any useful ?
    I mean that what situation should I use the "clone " method?
    Thks!

    a regular clone copies all members of an object by reference. You can implement the Clonable interface to provide a clone which makes a 1:1 copy of your object, so no references are copied over. This ensures that the objects don't share the same objects, but do have the exact same content.

Maybe you are looking for

  • Images in solaris

    Hi, I need help . I have an application in Sun Java Application Server in SOLARIS, that contain an image with cewolf. But the image do not appear in the application. I tried in windows and the image appear well. How I do to the image appear?? Please

  • Photomerge in CC not working

    I have 5 files of 11.2MB each I want to merge for a panorama. It takes 1minute in CS6 to complete the process and render a perfect panorama. In CC, Alignment of  Layers is laborious and uses max CPU resources. "Blending Selected Layers Based On Conte

  • Upgrade failed

    I got an online message saying: "Lightroom Update Available"  5,3 Current version: 5.2 (built 922700). I pressed the button "Download". Then I got an errormessage: "Page not found" Error returned 404. What´s wrong..? Karsten Frisk

  • EEM/TCL - 881W

    Hi, I am currently searching for a method to use an Ethernet interfaces as a backup route to a primary Cellular connection. The catch is that the FastEthernet port needs to enabled/disabled based on Cellular signal strength. Alternatively the Etherne

  • Delete solo records

    This is about writing a SQL statement. If I have a table like the following TABLE: PEOPLE +==========+=========+=======+ :FIRST_NAME:LAST_NAME:IGNORE : +==========+=========+=======+ |Ricky     |Ricardo  |   null| +----------+---------+-------+ |Lucy