N
N
Nikita Filatov2015-09-15 15:22:42
Java
Nikita Filatov, 2015-09-15 15:22:42

Is it possible to create an array of objects in java?

I need to enter the n-th number of points, or rather their coordinates. I created a class Dot, it has 3 fields x,y,z. Is it possible to create an array from objects of class Dot. That is, Dot dot[] = new Dot[0]. And how can I then add x,y,z values ​​to these objects. Because it is not possible to add it through the constructor.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abs0lut, 2015-09-15
@abs0lut

Can.
Why?

Dot dots[] = new Dot[];
dots[0] = new Dot(5, 5, 5); // конструктора Вашего не видел, поэтому скорректируйте под свою сигнатуру

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question