Answer the question
In order to leave comments, you need to log in
Question about how the code works?
(here is a digression, the main point is in the QUESTION part)
And so I welcome everyone for a while I was registered, but now I decided to ask a question (a couple have accumulated) I
started studying programming languages, I decided to abandon the "all at once" model, I was C # and Java, but stopped so far in Java
(by the way, I will be very grateful for all kinds of books both in Java and in mathematics (you need to raise the bar, otherwise I have already forgotten everything in terms of mathematics, there are school books for repetition, but then I think you still need to broaden your horizons with something academic, if this is of course will be strongly needed))
QUESTION-------------
There are actually several of
them 1. How is the process of creating new units in strategies? (I think it's better to associate this question)
(in my opinion, this is something like this, we have an array of the unit type in which, when creating a new unit, we write a new object of the unit class with all its parameters and then interact with its fields along the way, such as if we beat it, then we subtract xn and in this key)
2. What is an array of objects in general?
(tobish it just stores references to objects in itself, or everything is much more complicated there)
3. And the question about the description of an array element, what does it tell us about?
(here, for example, when I display just an element of the array, I get something like the following "[email protected]", that's what it is exactly, the first one is the package and the class in it, but then)
Answer the question
In order to leave comments, you need to log in
What is a unit is generally unclear.
There is a class.
There are instances of this class - objects.
An array of objects is a list that stores references to specific objects.
By displaying an array element, you can probably see the class name and object identifier of this type (class).
In your question, you are very confusingly throwing the words package, class, element, unit and parameters, confusing them with each other.
For example, an object should not have parameters - a method has them. An object can have methods and attributes.
Understand the terminology, write down definitions on a piece of paper so as not to get confused yourself and not to confuse others. And many things will immediately fall into place.
In fact, the array stores references to objects and that's it. Unless it is worth mentioning that these links lie in memory sequentially, in one continuous piece, in an array.
An example of when they may be out of sequence is a linked list, LinkedList in Java.
[email protected] is what gave the toString() method by default. Full qualified name + @ + the address where the specific object lies. You can override the toString() method of the Box class so that it produces something meaningful.
For example
class Box {
private int x, y;
@Override
public String toString(){
return Box.class.getName() + "[x: " + x + ", y: " + y + "]";
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question