# array manipulation

September 9, 2008 at 12:54 PM

Hi friend,

class ArrayMerge
{
public static void main(String[] args)
{
ArrayMerge am = new ArrayMerge();
int a[] = {1, 2, 3};
int b[] = {4, 5, 6} ;

int ar[] = am.middleWay(a, b);
for(int i=0;i<ar.length;i++)
{
System.out.println("ar["+i+"]" + ar[i]);
}
}

public int[] middleWay(int[] a, int[] b) {
int mida = a.length/2;
int midb = b.length/2;

int result [] = new int[2];

result[0]=a[mida];
result[1]=b[midb];

return result;
}

}

http://www.roseindia.net/java/beginners/arrayexamples/index.shtml

Thanks

Related Tutorials/Questions & Answers:
array manipulation - Java Beginners
array manipulation  We'll say that a value is "everywhere" in an array if for every pair of adjacent elements in the array, at least one of the pair is that value. Return true if the given value is everywhere in the array
Trouble with array manipulation
Trouble with array manipulation  For this project I have to print 10..., print the first index at which the maximum of the array occurs, and create an array b which has the same values as a only in reverse order, and print out
array manipulation - Java Beginners
array manipulation  Given 2 int arrays, a and b, each length 3, return a new array length 2 containing their middle elements. middleWay({1, 2, 3}, {4, 5, 6}) ?¨ {2, 5} middleWay({7, 7, 7}, {3, 8, 0}) ?¨ {7, 8} middleWay
string manipulation
string manipulation  Write a program in java and accept 10 strings form the user. store them in an array. then find the string with the maaximum length and print
in_array
in_array  in_array in php
is _array()
is _array()  is_array() in php   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php \$yes = array('Hello', 'World'); echo is_array(\$yes) ? 'Array
is _array()
is _array()  is _array()   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php \$yes = array('Hello', 'World'); echo is_array(\$yes) ? 'Array
Manipulation of war fie contents
Manipulation of war fie contents  How can I manipulate a specific file inside my war file without extracting it? Please help... Thanks and regards, Swapnil
string manipulation in xml
string manipulation in xml  im working on build.xml using apache ant... in one of the targets i am assigning a var file with the full path of .sql files present in a folder. while executing that .sql file in xml its giving me
Image Manipulation in Swing AWT
Image Manipulation in Swing AWT  Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later
ModuleNotFoundError: No module named 'data-manipulation'
ModuleNotFoundError: No module named 'data-manipulation'  Hi, My... named 'data-manipulation' How to remove the ModuleNotFoundError: No module named 'data-manipulation' error? Thanks   Hi, In your
Array
Array  how can i use elements of an array in a circular form? that is if the searching of the element reach the last elements of the array, then it will start serching from the begining of the array
Array
Array  is it possible to define array like this..? int[] intArray = new int[] {4,5,6,7,8}; Explain...?   Yes, you can. Java Initialize Array
Array
Array  What if i will not declare the limit index of an array, how will I declare an array and store values with it using loop?   Hi Friend... Scanner(System.in); int array[]=new int[5]; System.out.println("Enter
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
Array
Array  How do i insert elements into an array up to a limit from...("Enter Range: "); int size=input.nextInt(); int array[]=new int[size]; System.out.println("Enter Array Elements: "); for(int i=0;i<
array
array  WAP in java to store 6 element in array P and 4 element in array Q. Produce the third arra y R containing all element from p & q
Array
Array  can we create an array of size 1 lakh in java programming
array
array  array memory allocation is dynamic or static in java   Java Arrays have dynamic memory allocation
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element
array
array  take a 2d array and display all its elements in a matrix fome using only one for loop and ple explain the program in below
array
accepts a pointer to integer which represents an array of integer.After that this method prints the entire of the array numbers to the monitor. include using std::cout; using std::endl; void printArray(int *array, int count
array
array  How to store the results of mysql query in an array... qurey in array: "select distinct(EMPLID)from tblwork where EMPLID not in (select... store the result in array
array
array  wap to calculate reverse of 10 elements in an array?  ...(); } System.out.print("Array is: "); for(int i=0;i<arr.length;i...(); System.out.print("After reversing, Array is: "); for(int i=arr.length-1;i>=0
Array's
Array's  I have to finish an "order page". that checks 2 dropdown boxes and a set of radio buttons and put the results into a set of textboxes, 1 line at a time, then calculate a total. I know I need to create an array, but I'm
array
array  Hi i have array like {1,2,3,4,,5,5,6,6} then how can i... is an example that store some integers into an array and find the occurrence of each number from the array. import java.util.*; public class SearchNumberOccurrence
array
array  how to getting values and storing values in array by using datainputstream?   Hi Friend, Try the following code:ADS_TO_REPLACE_1...("Array Elements are: "); for(int i=0;i<arr.length;i
Array
reserved. Use a one-dimensional array of primitive type Boolean to represent the seating chart of the cinema theater. Initialize all the elements of the array... the corresponding elements of the array to true to indicate that the seat is no longer
ModuleNotFoundError: No module named 'cloudsat-object-manipulation'
ModuleNotFoundError: No module named 'cloudsat-object-manipulation'  ...: No module named 'cloudsat-object-manipulation' How to remove the ModuleNotFoundError: No module named 'cloudsat-object-manipulation' error
ModuleNotFoundError: No module named 'cloudsat-object-manipulation'
ModuleNotFoundError: No module named 'cloudsat-object-manipulation'  ...: No module named 'cloudsat-object-manipulation' How to remove the ModuleNotFoundError: No module named 'cloudsat-object-manipulation' error
ModuleNotFoundError: No module named 'cloudsat-object-manipulation'
ModuleNotFoundError: No module named 'cloudsat-object-manipulation'  ...: No module named 'cloudsat-object-manipulation' How to remove the ModuleNotFoundError: No module named 'cloudsat-object-manipulation' error
ModuleNotFoundError: No module named 'django-dynamic-manipulation'
ModuleNotFoundError: No module named 'django-dynamic-manipulation'  ...: No module named 'django-dynamic-manipulation' How to remove the ModuleNotFoundError: No module named 'django-dynamic-manipulation' error? Thanks
Working with CSS(CSS Manipulation)
Working with CSS(CSS Manipulation)       Working with CSS(CSS Manipulation) These methods are used to manipulate CSS specially by getting and setting
Mysql Date Manipulation
Mysql Date Manipulation       Mysql Date Manipulation find out the difference between two values... an example from Mysql Date Manipulation. To grasp this example, we create a table
PHP Push Array to Array
PHP Push Array to Array  array_push() function using array in PHP
could not execute native bulk manipulation query
could not execute native bulk manipulation query  I am insert data in mysql through struts hibernate integration. But above error is coming. Please help me I am sending our Insert Class coding My Insert class coding package
Data Manipulation Statements
Data Manipulation Statements       Data Manipulation Statement is used to retrieve, insert, update... the following Data Manipulation Statements : Select Statement Insert Statement
Array sort
Array sort  Program that uses a function to sort an array of integers
array example
array example  giving input from outside for array example
length in array
length in array  wat s length in array
Java array
Java array   How can one prove that the array is not null but empty