473,408 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Problem in assigning values to 2-dimensional arrays...

38
Hello,

I'm doing a project in java and im not able to assign the values which are got from for loop to the 2-dimensional array.
Can anyone tell me how to assign the values and print them?

the code is:
Expand|Select|Wrap|Line Numbers
  1.                            gr.getGridArray();
  2.                for (int s=0;s<=NoOfElevations;s++)
  3.                    for (int t=0;t<=NoOfElevations;t++)
  4.                    {
  5.                             temp[][] = ;
  6.                             System.out.println("values are " + temp[s][t]);
  7.                    }
  8.            } 
  9.  
How will i assign s and t values to temp array?

Thanks in anticipation.......
Dec 3 '07 #1
6 2877
dav3
94
Hello,

I'm doing a project in java and im not able to assign the values which are got from for loop to the 2-dimensional array.
Can anyone tell me how to assign the values and print them?

the code is:
Expand|Select|Wrap|Line Numbers
  1.                            gr.getGridArray();
  2.                for (int s=0;s<=NoOfElevations;s++)
  3.                    for (int t=0;t<=NoOfElevations;t++)
  4.                    {
  5.                             temp[][] = ;
  6.                             System.out.println("values are " + temp[s][t]);
  7.                    }
  8.            } 
  9.  
How will i assign s and t values to temp array?

Thanks in anticipation.......
I havnt worked with 2d arrays much but line 5 looks like it has a problem.
Dec 3 '07 #2
heat84
118 100+
Hello,

I'm doing a project in java and im not able to assign the values which are got from for loop to the 2-dimensional array.
Can anyone tell me how to assign the values and print them?

the code is:
Expand|Select|Wrap|Line Numbers
  1.                            gr.getGridArray();
  2.                for (int s=0;s<=NoOfElevations;s++)
  3.                    for (int t=0;t<=NoOfElevations;t++)
  4.                    {
  5.                             temp[s][t] =someValue ;
  6.                             System.out.println("values are " + temp[s][t]);
  7.                    }
  8.            } 
  9.  
How will i assign s and t values to temp array?

Thanks in anticipation.......
You assign someValue to the array at [s][t] . Is your problem solved?
Dec 3 '07 #3
sumuka
38
You assign someValue to the array at [s][t] . Is your problem solved?
Thanks for replying .
But i need to assign the values of s and t which i've used in the for loop .
I need to assign the values of s and t to this array and then display.

Please help....
Dec 3 '07 #4
JosAH
11,448 Expert 8TB
Thanks for replying .
But i need to assign the values of s and t which i've used in the for loop .
I need to assign the values of s and t to this array and then display.

Please help....
Variables s and t are *two* values; a single cell in a two dimensional array can
just contain *one* single value.

kind regards,

Jos
Dec 3 '07 #5
samido
52
Thanks for replying .
But i need to assign the values of s and t which i've used in the for loop .
I need to assign the values of s and t to this array and then display.

Please help....
dude, s&t are not the values of the array but index's, two dimentional array has pair of number to form a specific index of theh array value, for example arr[1][0] is the value at second horizontal line but first in the vertical line of you dimenssions, do you want the index(position) of the value or do you want the value? ...
Dec 3 '07 #6
heat84
118 100+
Thanks for replying .
But i need to assign the values of s and t which i've used in the for loop .
I need to assign the values of s and t to this array and then display.

Please help....
Ok , you can create an object e.g MyValues that that contains the s and t as instance variables.
for example
Expand|Select|Wrap|Line Numbers
  1.  
  2.    1.
  3.       gr.getGridArray();
  4.    2.
  5.                      for (int s=0;s<=NoOfElevations;s++)
  6.    3.
  7.                          for (int t=0;t<=NoOfElevations;t++)
  8.    4.
  9.                          {
  10.                     MyValues someValue=new MyValues(s,t);
  11.    5.
  12.                                   temp[s][t] =someValue ;
  13.    6.
  14.                                   System.out.println("values are " + temp[s][t]);
  15.    7.
  16.                          }
  17.    8.
  18.                  }
  19.  
In this case the tempArray then will have to be of MyValues type.

Hope this is helpful.....
Dec 3 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dave | last post by:
I am trying to create a function in SQL 2000. Im rusty on function syntax and need to also assign some variables for use within this function. Example: create function blah (@param1 int) ...
8
by: nick | last post by:
In the web site http://greywolfdesign.com , there is a pop-up menu (when mouse over 'Portfolio' menu item), it always works well when using IE (6). However, when using Mozilla 1.6, the popup...
2
by: Bogdan Zamfir | last post by:
Hi, I have a problem with err.raise I write a class module, and I want to use this mechanism to indicate errors when user set wrong values to properties But it seems the error is never raised...
14
by: Eric Bantock | last post by:
Very basic question I'm afraid. Once an array has been declared, is there a less tedious way of assigning values to its members than the following: myarray=8; myarray=3; myarray=4; myarray=0;...
8
by: Ricardo Sta. Rita | last post by:
Hello people, We have been dealing with for a long time now. It's a bit weird for a newcomer like us so we decided to ask the geniuses here. C# doesn't seem to be assigning values, consider...
2
by: SteveK | last post by:
I will just use code, I think that will be easiest way to explain this. public struct Something { public string Name; }
4
by: ^MisterJingo^ | last post by:
Hi all, I have a web page which has a single dropdownlist containing 3 items. Below the dropdownlist are two listboxes. Depending on the option selected from the dropdownlist, the left most...
1
by: cweibel | last post by:
This should be an easy problem for those with far more knowledge than myself with databinding. I have a VB.NET 2005 windows form with several checkboxes, textboxes and datepickers which are...
1
by: timdelong1 | last post by:
I was writing a usercontrol in ASP.NET that contained an objectdatasource, a gridview, and some other form controls (textboxes and dropdown lists). For the insertcommand parameters I associated...
10
by: biplab | last post by:
Sorry to bother again u people with the same code.....but another astonishing problem arising....please help me.... #include <stdio.h> #include <stdlib.h> #include <dos.h> #include <mem.h>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.