473,387 Members | 1,534 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,387 software developers and data experts.

hello all, Is there a package or Inbuilt class

6
In JAVA Which return or printout the max, min element position in a 2d array...

give me the code of that program if possible...?
Feb 18 '07 #1
3 1810
horace1
1,510 Expert 1GB
In JAVA Which return or printout the max, min element position in a 2d array...

give me the code of that program if possible...?
post the code you have so far - also have a look at the tutorial on Java arrays
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
Feb 18 '07 #2
shailu
6
post the code you have so far - also have a look at the tutorial on Java arrays
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html


hi....yah,,,,it was a good link.....I have made this program in c and c++
but If u know classes and packages in java that deal with 2d array...
like they accept an 2d array ref. and print the position of max and min array element....if there is something like this available in java please let me know....I will be thankful.....reply soon.....
Feb 18 '07 #3
DeMan
1,806 1GB
The implementation would be reasonably similar to code.
If you create 2 methods (let's be creative and call them min and max).

Min would work something like this (this should give an idea of the logic, not necessarily exactcode):

Expand|Select|Wrap|Line Numbers
  1. void min(int[] input)
  2. {
  3.   int min =input[0];
  4.   int minIndex = 0;
  5.   for(int i=0; i<input.size; i++)  // I can never remember whether Java likes length or size
  6.   {
  7.     if(input[i] < min)
  8.     {
  9.       min = input;
  10.       minIndex = i;
  11.     }
  12.   }
  13.   System.out.println("The minimum value was at index: " + minIndex);
  14. }
  15.  
The max method would be implemented in a similar way, and if you wanted you could return either the index or the actual value to the calling function
Feb 18 '07 #4

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

Similar topics

2
by: G. Ralph Kuntz, MD | last post by:
Step on my soapbox... :-) I believe that the "final" keyword is underused in Java. I have gotten into the habit of using it on EVERY method parameter, instance variable, and local variable...
36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
27
by: Marc Reinig | last post by:
I have a program written in Visual Studio 2003 Visual Basic. I would like to move it to Visual C++. Is there an automated or relatively automated way of doing that, or do I need to recreate all...
5
by: selimsivad83 | last post by:
Hi everyone, Thinking in Java, 4th edition, p 232: ... if you don't put an access specifier for class access, it defaults to package access. ... However, if a static member of that class is...
13
by: ragav | last post by:
How can i print anything without using printf( ) or anyother inbuilt function calls??
0
by: mirandacascade | last post by:
When I review: - the site that describes the SSLCrypto package: http://www.freenet.org.nz/python/SSLCrypto/ - the documention for SSLCrypto: http://www.freenet.org.nz/python/SSLCrypto/Doco/ -...
1
by: James T. Dennis | last post by:
You'd think that using things like gettext would be easy. Superficially it seems well documented in the Library Reference(*). However, it can be surprisingly difficult to get the external details...
2
by: MAXX | last post by:
is there a inbuilt function as ArrayList in c#?
2
by: Dmitry | last post by:
Hi All, I've trying to develop one Python application, and neet to solve one problem. I need to list all classes defined in one package (not module!). Could anybody please show me more...
2
by: Cirene | last post by:
I reformated by PC, reinstalled VS2008 then tried to apply the SP1 (using a DVD I burned from the ISO.) Can you help??? I got this message... The installation failed with teh following...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.