Questions tagged [objectinstantiation]
92 questions
0
votes
1 answer
Will static variable in non-instantiated class be initialized via call to Toolkit?
I want to be able to adjust click interval in a program IF the user wishes to do so, at which point class ClickAdjustmentFrame would be instantiated.
It had seemed sensible to have CLICK_FREQUENCY initialized in the only class where its value could…

DSlomer64
- 4,234
- 4
- 53
- 88
0
votes
1 answer
Best approach of Creating String Object
In java we can create String in the following 2 ways -
String str1 = new String("first string"); //1
String str2 = "second string"; //2
Is there any difference in performance with these 2 approaches? And in the second case is there any new…

Razib
- 10,965
- 11
- 53
- 80
0
votes
1 answer
Converting Java to C# - Override on Instantiation
I'm having difficulty converting the below code from Java to C#.
this.document.add(new VerticalPositionMark() {
@Override
public void draw(final PdfContentByte canvas, final float llx, final float lly, final float…

Display_Here
- 311
- 1
- 10
0
votes
4 answers
Copy of object by passing as method parameter
I am a bit confused about Java's pass by reference/values in method parameters.
I have a constructor in an OuterObject class:
private InnerObject io;
public OuterObject(InnerObject io){
this.io = io;
}
public InnerObject getInnerObject(){
…

MidgarZolom
- 195
- 5
- 15
0
votes
2 answers
java instantiating object without knowing which subclass it will belong to until runtime
Scenario:
I have a hierarchy of subclasses all inheriting from a single distance ancestral class. All super classes in the hierarchy are abstract, so the only concrete classes are those without subclasses. I have an array:
AncestralClass[]…

user4240561
- 1
- 1
0
votes
1 answer
How do I allow for infinite object instantiation?
I'm currently stuck on a Java program. My program, a city-builder game, needs the ability to instantiate objects at any moment based on the user's whim, and the number of objects needs to be infinite.
The program is going to have a Building type…

Andrew
- 79
- 3
- 12
0
votes
2 answers
Dynamic Type instantiation C#
I'm looking to instantiate an object at runtime having its type in a string but also it's value in a string. eg:
string myType = "System.Int32";
string myValue = "3";
I'm looking to create an instance of myType and cast/assign myValue into the…

Caracole
- 13
- 1
- 5
0
votes
1 answer
Can i instantiation my superclass by using my subclass?
deck is my superclass and playingCardDeck is my subclass of deck.
i found that i can i instantiation my superclass by using my subclass which confuse me a lot.
Can you tell me about this.Which init method will be used and any other features about…

cozybed
- 3
- 3
0
votes
1 answer
compile error during build when initialize an object from static library
I have the following compile error when try to create and initialize an object in Data parser class. The code is
Component *component=[[Component alloc] initWithInputComObjects:inputComObjects withOutputComObjects:outputComObjects];
where…

user3347073
- 137
- 1
- 5
0
votes
3 answers
Why declare and instantiate temp object in constructor instead of real object?
Forgive me if this has an answer somewhere; I didn't really know what to search for... Also, my terminology may be off (declare, instantiate, etc) as I am still learning Java and OOP.
I was reading the textbook: Data Structures and Abstractions, 3rd…

Kurt E. Clothier
- 276
- 1
- 11
0
votes
2 answers
Javascript - instantiate an object which it's properties had been modified
Edited:
Say i create a constructor to create my own user-defined objects:
var Person = Person(age) { this._age = living; };
and i find during runtime that i need to add to the objects that are created by this constructor another property,so i use…

Avishay
- 305
- 1
- 11
0
votes
1 answer
PHP class instantiation from variable and use keyword
could I ask about one clarification? At the top of my file i used (Silex context):
use Symfony\Component\Validator\Constraints as Assert;
Lets say I have an array $asserts with asserts names as strings:
'Assert\\NotBlank()',
'Assert\\Date()'
When…

Kamil
- 221
- 1
- 2
- 11
0
votes
3 answers
How to instantiate an ArrayList already containing multitudinous String[1]?
private ArrayList action = new ArrayList();
Suppose my goal with the above is to fill action with twenty empty String[3]. The quickest way I know of is:
for(int i = 0 ; i < 20 ; ++i) {
action.add(new String[3]);
}
Is there…

user2763361
- 3,789
- 11
- 45
- 81
0
votes
2 answers
Unable to create a new instance in javascript
the following is my code,
function hostile(x, y) {
this.speed = 1;
this.health = 100;
this.x = x;
this.y = y;
this.height = 32;
this.width = 32;
this.isDead = false;
this.direction…

tommy knocker
- 371
- 1
- 7
- 19
0
votes
2 answers
Instantiation of objects
If I use multiple instances of the same object in my code, do the instance methods for each separate object require memory, or do all of those objects share the same instance methods?
It could have a big effect on memory use.
Thanks in advance for…

John R Doner
- 2,242
- 8
- 30
- 36