473,494 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to pass two dimensional array in Java

29 New Member
Hi all,
I am trying to pass a two dimensional in java but there a problem in this function
Expand|Select|Wrap|Line Numbers
  1.  
  2.     public static void doOutput(String args[], double vector[][40])   
  3.  
Please what is the problem in this line
Feb 23 '08 #1
3 9177
chaarmann
785 Recognized Expert Contributor
As far as I know, you cannot pass size of dimensions!
And it's better to use different syntax, not C++ syntax.

So just write
Expand|Select|Wrap|Line Numbers
  1. public static void doOutput(String[] args, double[][] vector)  
and it should work.

You can get the size of the passed array with vector.length .
By the way, in opposition to C++, each element of the array can have a different size. So vector[0].size and vector[1].size can be different!
That's much better than hardcoding the size of the second index to 40, isn't it?

Hi all,
I am trying to pass a two dimensional in java but there a problem in this function
Expand|Select|Wrap|Line Numbers
  1.  
  2.     public static void doOutput(String args[], double vector[][40])   
  3.  
Please what is the problem in this line
Feb 23 '08 #2
aeo3
29 New Member
That's right. It works now. Thanks
Feb 24 '08 #3
r035198x
13,262 MVP
As far as I know, you cannot pass size of dimensions!
And it's better to use different syntax, not C++ syntax.

So just write
Expand|Select|Wrap|Line Numbers
  1. public static void doOutput(String[] args, double[][] vector)  
and it should work.

You can get the size of the passed array with vector.length .
By the way, in opposition to C++, each element of the array can have a different size. So vector[0].size and vector[1].size can be different!
That's much better than hardcoding the size of the second index to 40, isn't it?
Hopefully, chaarmann, you will check your PM and respond to me ....
Feb 25 '08 #4

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

Similar topics

2
2349
by: Te-Jung Lo | last post by:
the following is the original code i wrote #include <stdio.h> #include <stdlib.h> //--- Prototype ---// void bfs(int ); void main()
15
6944
by: Paul Morrison | last post by:
Hi all, I need to come up with some differences between arrays in Java and C, I have searched Google and so far all I have found is the following: Arrays in Java are reference types with...
3
2819
by: questions? | last post by:
I tried to pass a two dimensional array in the function arguments the following program is a demonstration, ******************************************** # include <stdio.h> # include...
8
11782
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious...
19
2064
by: DarelRex | last post by:
Is it possible to pass a 2-D, statically defined array? Here's a 1-D example that won't work: void foo() { int myArray ; bar(myArray); } void bar(int *arr) {
2
3950
by: tiberiu.motoc | last post by:
Hi. I've asked this question on the MSDN forums, but I've had no replies. I'm really stuck, so I'm gonna try my luck here. I have a Java web service which contains a simple function; the...
5
3860
by: nelly0 | last post by:
developing a program that will manipulate noise levels (measured in decibels) that is collected by car manufacturers. These noise levels are produced at seven different speeds by a maximum of six...
10
2252
by: Bernhard Reinhardt | last post by:
Hi, I read data from a file into a 4 dimensional array. The data has a size of 5MB (could later be up to 500MB). I want to pass the matrix to subroutines. What is the cleverst (and for a...
29
38657
by: Why Tea | last post by:
Suppose you have a 2-dimensional array (matrix) in main() and you want to pass it to a function to do some processing, you usually pass it as a pointer to the first element. But, from the function,...
0
6989
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
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
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
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5453
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,...
1
4889
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...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.