answersLogoWhite

0

A "static" method belongs to the class, not to any particular instance. So make it static method.

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

How do you get odd ascii letters from a given string using string copy?

there is no such method using string copy


What is a bit copy?

A bit copy of an object is an exact, bit-by-bit, copy of that object. The default copy constructor generated by the compiler makes a bit copy. This is potentially a problem if the object contains pointers to other objects... A bit copy of a pointer copies the pointer, but not its data. This means that you have two pointers pointing at the same object in memory. If you delete one of them, the other becomes invalid, and this can (usually does) cause corruption. If an object contains a pointer, the object's copy constructor should provide for proper allocation and copying of any pointed to objects within that object.


How pass by value and pass by reference work in Java explain with example?

In principle, values are always passed by reference (a copy of the value provided is copied onto the stack, the receiving method accesses this).In the case of objects, this value is the memory address of an object. In other words, the object itself is not copied - only a copy of the address is made. Therefore, the receiving method works with the SAME object, and any changes will be reflected back to the calling program. The result is that, for all practical purposes, this works as if the object is passed by reference.


What is difference between Deep copy and shallow copy?

A "shallow" copy is when the member values are physically copied from one object to another, *including* the values of any pointer or reference members. If there are pointer or reference memebrs, then, those poointers or references refer to the *same* objects as the original object, which is usually a bad thing. That's why you want to define a copy constructor and assignment operator for objects that contain pointers or references. It's called a "shallow" copy because only the values of the pointers/references are copied, instead of making copies of those referred-to objects and setting pointers to them. *That* is what would be called a "deep" copy, because it's going "deeper" into the structure, copying everything, not just the first "layer".


What is shallow copy in Java?

A shallow copy in Java refers to the copying of object references from one collection to another. In contrast, a deep copy in Java refers to the copying of actual object data from one collection to another. // shallow copy Object[] original = {new Object(), new Object(), new Object()}; Object[] copy = new Object[original.length]; for(int i = 0; i < original.length; ++i) copy[i] = original[i]; // deep copy Object[] original = {new Object(), new Object(), new Object()}; Object[] copy = new Object[original.length]; for(int i = 0; i < original.length; ++i) // this would not compile in this case because Object does not have a publicly // accessible clone() method. if you were to use this, make sure that the type // has an accessible clone() method copy[i] = original[i].clone();

Related Questions

When do you declare a member as static?

In the case a Java, if a variable at the class level (called a "field" in Java) is declared as static, a single copy of such a variable exists, no matter how many objects are created for the class. This lets you share information between different objects; you can also access such a variable without creating a single object, using the class name. A good example are the fields Math.PI and Math.E, i.e., fields in the "Math" class which you can access without creating an object based on the class.


What gives you the right to copy software onto a single computer?

gives you the right to copy software onto a single computer


How do you share outlook pst files?

You can only share Outlook PST File by creating copy of it.


Is it safe to share a passport copy online?

No, it is not safe to share a passport copy online as it can lead to identity theft and fraud. It is important to keep personal identification documents secure and only share them with trusted entities when necessary.


Which is better in structure or class?

It depends on your requirements. A structure contains other objects (variables) within it. You cannot write methods in a structure. It is used as a data storage mechanism. When passed as an argument to another method, the entire contents of the structure is copied (this means that any changes you make to the structure in that method only apply to the local copy). A class contains both objects (variables), and methods that interact on those variables. Classes are the fundamental building block of object orienated applications. When passed as an argument to another method, only the pointer (or memory location) of the object is passed to the method (this means that any changes you make to the object will be visible in the original method as well, since there is only one copy of it).


How do you get odd ascii letters from a given string using string copy?

there is no such method using string copy


An alternative method to copy a file is by pressing what?

Ctrl + C


How do you share your room on meez?

all you have to do is go to your room and click on share room and the copy the URL on the address bar.


When a copy constructor is invoked?

When a copy constructor is invoked, it creates a new object by copying the values of another existing object. This is typically used when passing objects by value, returning objects from a function, or when explicitly creating a new object as a copy of an existing one.


Can you copy a song but not share it?

No. You know why? Because that's stealing someone's song idea. You can't just copy it. Even "if",you copy the song and don't share it. It's still stealing someone's song idea. It's "their",property of "their",song. You here me people!?!?!? You here me?!?!?!


Always has a single copy of genetic information?

chromatid


What is the important of the cells ability to copy single DNA sequence into RNA?

The ability to copy a single DNA sequence into RNA makes it possible for a single gene to produce hundreds or even thousands of RNA molecules.