Questions tagged [cloneable]

163 questions
1
vote
3 answers

Why it is possible to directly use Interface's method

I was reading about java and saw this code : public class Person implements Cloneable{ public Object Clone(){ Object obj = null; try{ obj = super.clone(); } catch(CloneNotSupportedException ex){ …
SnuKies
  • 1,578
  • 1
  • 16
  • 37
1
vote
2 answers

Cloning a Form in jQuery and Increasing the Index

This seems relatively simple, I'm just stumped on jQuery syntax. Basically I want to take this form :
1
vote
3 answers

How to clone multiple inheritance object?

I have defined a Cloneable interface: struct Cloneable { virtual Cloneable * clone(void) const = 0; } I have also some other interface classes (content not relevant to issue): struct Interface { }; struct Useful_Goodies { }; I have created a…
Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154
1
vote
1 answer

Implementing the Java Cloneable Interface

I am not sure on how to implement the Cloneable Interface in my Complex class. I have implemented the Comparable but i just cant seem to figure out the Cloneable. I have the following example code that I am using to try and get my head around it. I…
Kamal
  • 37
  • 2
  • 10
1
vote
2 answers

What can I use in place of a "long" that could be cloneable?

What can I use in place of a "long" that could be cloneable? Refer below to the code for which I'm getting an error here as long is not cloneable. public static CloneableDictionary returnValues = new CloneableDictionary
Greg
  • 34,042
  • 79
  • 253
  • 454
1
vote
2 answers

Purpose of cloning in Java

I was going through the "special" features of Java, and started reading up on Cloning. So currently what I understand is Cloning can be used to get a identical copy of an object. To do this you implement the Cloneable interface and override the…
Desert Ice
  • 4,461
  • 5
  • 31
  • 58
1
vote
1 answer

Java deep copy - wrong reference assignment

Please consider the following code public class Pair implements Cloneable, Comparable { ... public Pair(String key, double value) throws Exception { if (value <= 0) throw new IllegalArgumentException(); this.key =…
Mateusz Kowalski
  • 205
  • 3
  • 10
1
vote
1 answer

Implementing the Cloneable Interface

Please Note: I created a post earlier that had this question along with several others, but was told that since I was asking so many questions in the same post, it'd be better to break it up into individual questions. So please do not mark this as a…
user2932587
1
vote
1 answer

Which class throws the CloneNotSupportedException? OR Where is the instanceof Cloneable is checked?

To clone an object of a class we implement the Cloneable interface, and override the clone method: protected Object clone() throws CloneNotSupportedException{ return super.clone(); } The above super.clone() calls Object's native API…
ambar
  • 2,053
  • 6
  • 27
  • 32
1
vote
1 answer

Explanation about the clone the array containing cloneable objects is needed

I am trying following code: public class cloneTest : ICloneable { public string strValue { get; set; } public object Clone( ) { cloneTest n = new cloneTest( ); n.strValue = this.strValue; return n; } } cloneTest…
User1551892
  • 3,236
  • 8
  • 32
  • 52
1
vote
1 answer

How can I exclude attributes from associations when using deep_cloneable gem?

I am using deep_cloneable gem. I can do deep copying of the association, and also I can exclude the attributes from the parent object. But is there a way to exclude the attributes even from the associations?
chetu
  • 245
  • 3
  • 15
1
vote
3 answers

How can we get immutable object if class did not implement cloneable

I have few issues/doubts to fill values in a HashMap I want a HashMap to accept "Student" as key and "Details" as value. Since key to a hashMap should be immutable I have some doubts how can this be dealt if Student class did not cloneable Student…
ksv
  • 37
  • 5
1
vote
1 answer

Copy/clone an object in Session

When I put an instance of a custom class into Session and then pull it out, I need it to come out as a COPY of what's in Session, not a reference to what's in Session. Here's what I have, watered down for example purposes. protected void…
CptSupermrkt
  • 6,844
  • 12
  • 56
  • 87
1
vote
1 answer

Java Drag & Drop and Cloneable

I have this problem to solve where you have a JPanel and JLabel and you have to clone JLabel with drag and drop and create a JLabel clone on the JPanel where JLabel was dropped. First thing I'd like to ask is if it's possible to implement Cloneable…
user1189571
  • 195
  • 3
  • 5
  • 10
1
vote
3 answers

Effective Java. Clonable interface

I read Effective Java book and don't understand one paragraph where explained Clonable interface. Can someone explain me this paragraph: ...programmers assume that if they extend a class and invoke super.clone from the subclass, the returned…
WelcomeTo
  • 19,843
  • 53
  • 170
  • 286