Questions tagged [cloneable]

163 questions
1
vote
4 answers

How can clone method be protected in Cloneable?

I have a very simple question (I guess!) How can clone method be protected in Cloneable interface while interfaces can only declare public methods?
Hassan Khallouf
  • 1,170
  • 1
  • 13
  • 30
0
votes
0 answers

Java override clone Methode or copy constructor

I have a existing class called "Customer". In this class, i want to create an EnumMap called "featureMap". The values in the EnumMap should implement the "FeatureInterface" interface. So far, I have only created the FeatureInterface, but I haven't…
MKue
  • 11
  • 3
0
votes
1 answer

Kotlin cloneable vs deep copy

I implemented various times copy and deep copy. Didn't use clone a lot so decided to investigate it. I have class: data class CountryResponse(var data: List): Cloneable { public override fun clone(): Any { return…
Kratos
  • 681
  • 1
  • 13
  • 30
0
votes
1 answer

How to make default `clone()` in an interface?

The following code compiles w/o errors: public interface ICloneable { default ICloneable clone() throws CloneNotSupportedException { throw new CloneNotSupportedException(); } public static void main(String[] args) { …
Dims
  • 47,675
  • 117
  • 331
  • 600
0
votes
1 answer

Cloneable interface in j2me

I want to implement cloneable interface but I am unable to. I am using J2me, it gives me error create interface Cloneable in your package. As far as I know J2me allows to implement Cloneable interface as it is a part of jdk1 1.0. Kindly help me
0
votes
3 answers

Pretty HABTM List Entry

I have a Recipe, Item, and Units table/model. I have a HABTM relationship with Recipe and Item, and I get the default multiple-select box when adding/editing Recipe. (am using Bake for everything for the most part). The problem is I need to…
mondo
  • 334
  • 1
  • 2
  • 8
0
votes
0 answers

How can I make someone review my code on GitLab and not give them permission to clone it?

My manager asked me to add a person to my GitLab repo to review it but this person should not be able to to clone it. Also, can I add a person but so they can see only the branches that I want them to see and not all branches? Thank you in advance.
0
votes
0 answers

After Object.clone, why is element's address in a nested ArrayLIst is different but not for a nested ArrayList?

Let's say I have a class Book and one of its attribute is an ArrayList of Strings with the names of the protagonists. When I call clone() on the Book, I expect it to do a shallow copy, i.e., the cloned Book object has its own memory location and…
Saffie
  • 445
  • 3
  • 15
0
votes
1 answer

How to use data events on cloned streams in cloneable-readable? : NodeJS

I want to clone a read stream. Currently, I am doing it using readable-stream-clone npm package. Using the code: const fs = require('fs') const readStream = fs.createReadStream('smallTextFile.txt', { highWaterMark: 5 }) const ReadableStreamClone =…
Mayank Patel
  • 346
  • 3
  • 18
0
votes
1 answer

rust lifetime question, why can't I move a structure '1 layer' up, how do I set the lifetime correctly?

I have a question for you, regarding my 'idx' structure and it's lifetimes... This structure is a cloneable multi threaded object. This code works, how is it that moving 'idx' one layer up suddenly meant it didn't satify the 'static' lifetime…
Chris Pugmire
  • 91
  • 1
  • 4
0
votes
1 answer

How does object class in java use cloneable interface without implementing it?

Attaching the snippet of clone method implementation from object class, although object class does not implement cloneable interface, how is it allowed to use it ? Another one : Why couldn't clone method could stay in cloneable interface instead of…
0
votes
1 answer

cloning an object some of whose properties are objects

I have a bit of a special exercise, here it is: If an X object has a property that contains an object then a clone of the X object will contain in its property the same instance that the X object contained. Modify the CloneMe class so that if an…
Evolution1980
  • 21
  • 1
  • 6
0
votes
0 answers

Why can't we use clone method by using approch 1(given below) instead of approch 2 and what's need of marker interface? Why jvm handle clone method?

approach 2 /*Using clone method by using marker interface and clone method control by jvm (recommended way)*/ class Employee implements Clonable { String name,id; Employee(String name,String id) { this.name=name; this.id=id; } public Employee…
0
votes
0 answers

ShallowCloning-Original Object doesnt gets affected

public class CreatingObjectusingCloneMethodShallowCloning implements Cloneable{ String name; int rollno; String housename; //Defining the clone method protected Object clone() throws CloneNotSupportedException { return…
0
votes
1 answer

Custom Marker Interface in Java

As Serializable and Cloneable is marker Interface (interface which is not having any method), so if we create our own marker interface then what will be the difference between these two.