Question

In: Computer Science

java declare at least five different types of arrays, one, two and three-dimension.

java

declare at least five different types of arrays, one, two and three-dimension.

Solutions

Expert Solution

if you have any question or queries just comment below. Thank you.

1. int:

1D: int[] arr = new int[n]; where n is number elements in array.

2D: int[][] arr = new int[n][m]; where n is number rows and m is number of columns.

3D: int[][][] arr = new int[n][m][l]; where n is array number, m is number of rows, l is number of columns.

2. String:

1D: String[] arr = new String[n]; where n is number elements in array.

2D: String[][] arr = new String[n][m]; where n is number rows and m is number of columns.

3D: String[][][] arr = new String[n][m][l]; where n is array number, m is number of rows, l is number of columns.

3. float:

1D: float[] arr = new float[n]; where n is number elements in array.

2D: float[][] arr = new float[n][m]; where n is number rows and m is number of columns.

3D: float[][][] arr = new float[n][m][l]; where n is array number, m is number of rows, l is number of columns.

4. double:

1D: double[] arr = new double[n]; where n is number elements in array.

2D: double[][] arr = new double[n][m]; where n is number rows and m is number of columns.

3D: double[][][] arr = new double[n][m][l]; where n is array number, m is number of rows, l is number of columns.

5. char:

1D: char[] arr = new char[n]; where n is number elements in array.

2D: char[][] arr = new char[n][m]; where n is number rows and m is number of columns.

3D: char[][][] arr = new char[n][m][l]; where n is array number, m is number of rows, l is number of columns.


Related Solutions

This program needs to be in Java Exercise on Single Dimensional Arrays Declare an array reference...
This program needs to be in Java Exercise on Single Dimensional Arrays Declare an array reference variable arrayInt for an array of integers. Create the array of size 100, and assign it to arrayInt. (2 points) Write a method to populate the array with Random numbers between 1 to 25. Signature of the method is: populateArray( int[] ) which returns nothing. Call this method from main with arrayInt--> populateArray(arrayInt). (2 points) Write a method to print an array. Signature of...
     program will enter data into two single dimension arrays (do not store duplicate values in arrays)...
     program will enter data into two single dimension arrays (do not store duplicate values in arrays)      program will find the union and intersection of the two arrays using one function      program will find the symmetric difference of two arrays      program will display the union, intersection, and symmetric difference   */     short* input_data(short size);   // function to dynamically allocate and array and enter data into the array void display_data(short *data, short size); // function to display data in an array void...
Java: Declare a two-dim array that represents five students with four test scores. Assign 100 for...
Java: Declare a two-dim array that represents five students with four test scores. Assign 100 for all tests to all students. Change the 3rd student’s test 2 to 50. Change the last student’s last test to 87 Print out all test scores. Calculate the total points of all tests of all students
Research at least five of your neighboring states and identify all of the different types of...
Research at least five of your neighboring states and identify all of the different types of property that are subject to taxes in those states. ((I LIVE IN NEW YORK)
There are three different types of tests we learned. What one of the three types is...
There are three different types of tests we learned. What one of the three types is the following? “ A researcher estimates that high school girls miss more days of school than high school boys. A sample of 16 girls showed that they missed an average of 3.9 days of school and a sample of 22 boys showed that they missed an average of 3.6 days. The standard deviation of the 16 girls was .6 and the standard deviation of...
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2....
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2. Pass arrays to method and return an array from a method Problem 2: Find the largest value of each row of a 2D array             (filename: FindLargestValues.java) Write a method with the following header to return an array of integer values which are the largest values from each row of a 2D array of integer values public static int[] largestValues(int[][] num) For example, if...
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2....
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2. Pass arrays to method and return an array from a method Problem 1: Find the average of an array of numbers (filename: FindAverage.java) Write two overloaded methods with the following headers to find the average of an array of integer values and an array of double values: public static double average(int[] num) public static double average(double[] num) In the main method, first create an...
Write a java program, creating three threads, to sort two arrays and merge them into a...
Write a java program, creating three threads, to sort two arrays and merge them into a third array. More specifically: Create a thread to sort the first array. Create a thread to sort the second array. Create a thread to merge the arrays into the third array. Let the main method prints the merged array. i want three threads to be created . You must call the two sorter threads together. In other words, if we name these threads sorta,...
Lab 7 - 2D Arrays (C++) In main, declare and fill a 2D array with one...
Lab 7 - 2D Arrays (C++) In main, declare and fill a 2D array with one hundred rows and fifty columns. Iterate through each element and assign it a random value between -72 and 75 inclusive. Have your random number seed be 25. Create functions that do the following: 1. A function called “sum” that returns the sum of all the elements in your 2D Array. 2. A function called “average” that return the average value of the elements in...
At least three different types of influence the gating of ion channels. (a)What are the types discussed in class?
At least three different types of influence the gating of ion channels.  (a)What are the types discussed in class?  (b)Select on type and describe it using a specific example. You may use an example not covered in lecture/textbook.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT