The Artima Developer Community
Sponsored Link

Java Answers Forum
multi array

6 replies on 1 page. Most recent reply: Sep 17, 2003 8:05 AM by David

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
Forrest

Posts: 2
Nickname: uu
Registered: Sep, 2003

multi array Posted: Sep 15, 2003 11:17 PM
Reply to this message Reply
Advertisement
hi all,

i am having a problem. How can I create use for loop to create multi arrays? thx.


Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: multi array Posted: Sep 15, 2003 11:59 PM
Reply to this message Reply
float[][] mat = new float[4][];
for (int y=0; y<mat.length; y++){
   mat[y] = new float[4];
}

Forrest

Posts: 2
Nickname: uu
Registered: Sep, 2003

Re: multi array Posted: Sep 16, 2003 12:49 AM
Reply to this message Reply
thank you very much.
i would like to ask a bit more.
i would like to create the number arrays, which depends on the user input. eg. user input 5, then create 5 arrays.

Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: multi array Posted: Sep 16, 2003 1:54 AM
Reply to this message Reply
I am not sure whether it is possible to create 5 different arrays since naming is going to be an issue. However what you could do is something like this...

create a two dim array based on the user input.
int userinput = 5;//get this value from the user
float[][] mat = new float[userinput][];for (int y=0; y<mat.length; y++){   mat[y] = new float[4];}


by the way whats the size of the each array you want to create?

zenykx

Posts: 69
Nickname: zenykx
Registered: May, 2003

Re: multi array Posted: Sep 16, 2003 3:06 PM
Reply to this message Reply
Sorry Senthoorkumaran Punniamoorthy you just solved somebody's homework. This way, he will never advance in Java. Maybe it's better to point him to the right direction. :=)

Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: multi array Posted: Sep 16, 2003 4:41 PM
Reply to this message Reply
See, I didn't think of it as a home work. I have seen people posting like I need to write a calculator, or I need to write a system which has XYZ features. Those I considered doing home work. These people expect us to do all the work for them.

But in this case the problem is not writing and entire system as a home work for someone. The guy has done some work and seems to have problem in a particular area which he/she is not clear about. helping out in those areas are not a bad thing in my opinion.

When they are putting some effort towards the problem me also giving a hand and encouraging them to do their work sounds rational to me.

David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: multi array Posted: Sep 17, 2003 8:05 AM
Reply to this message Reply
I agree with Senthoorkumaran. He's hardly written someone's entire project.

Flat View: This topic has 6 replies on 1 page
Topic: property??? Previous Topic   Next Topic Topic: ResultSet going out of scope

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use