Newbie question

  • Thread starter Reinert Korsnes
  • Start date
R

Reinert Korsnes

Newbie Java question (my main progamming experience is Ada95):

How do I make a new array (A) of length N and at the same time initiate it ?

I can do it this way:
------------------------------------------------
A = new int [N);
for (int i=0; i < A.length; i++){
A = 1;
}
------------------------------------------------

But I find it clumsy.

In Ada one can use:

A : array (0..N) of Integer := (others=>1);

Something I have been missing ?
Possible to do the java version short, elegant and readable/relyable ?

reinert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top