Solved

Creating a method that accepts two integer arrays as parameters

Posted on 2006-11-19
9
189 Views
Last Modified: 2010-03-31
Can I set up a method to do this? What would it look like?
0
Comment
Question by:msheppard74
  • 3
  • 3
  • 3
9 Comments
 
LVL 1

Expert Comment

by:bnblazer
ID: 17976403
public foo(int[] a, int[] b) {

// do something here

}
0
 
LVL 1

Accepted Solution

by:
bnblazer earned 400 total points
ID: 17976411
actually is would be like this (sorry typed too fast)

public void foo(int[] a, int[] b) {

// do something and assume no return value

}
0
 

Author Comment

by:msheppard74
ID: 17976432
What if I wanted to switch the elements of the two arrays? Usually, one array is longer than the other.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 16

Expert Comment

by:suprapto45
ID: 17976483
>>"What if I wanted to switch the elements of the two arrays? Usually, one array is longer than the other."
Can you explain more?
0
 
LVL 1

Expert Comment

by:bnblazer
ID: 17976495
If you could give an actual problem statement or some code we could be of much more help.
0
 

Author Comment

by:msheppard74
ID: 17976525
it's a hypothetical at this point. I don't have any code yet. I'm just looking for generic code or pseudo code to get me going.
0
 

Author Comment

by:msheppard74
ID: 17976529
I'm merely wanting to switch the contents of the arrays.
0
 
LVL 16

Assisted Solution

by:suprapto45
suprapto45 earned 100 total points
ID: 17976535
>>"switch the contents of the arrays."
You can loop the first array and compare it with second array and do the necessary logics that you want.
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17976577
;).

Glad I could help.

David
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question