[ICS4UI]Arrays Documentation

Arrays Class Assignment

The class Arrays contains the methods that operates the integer and string array.


Method Summary

Modifier and Type Method and Description
public static int[] makeArray:
Creates the new integer array and return created array
public static String[] createEmptyStringArray:
Creates the String array and return created array
public static int[] user_defined_array:
Creates the new integer array with user defined values and return the array using makeArray method
public static String[] user_defined_array:
Creates the new String array using createEmptyStringArray and fill with user defined values and return the array using makeArray method. Print the log into the filePrintWriter myOutputAllow the program to print to external file
public static int[] random_array:
Creates the new integer array with random values and return the array using makeArray method
public static void print_array:
Print the values of integer array from parameter
public static void printArray:
Prints the String array from parameter
public static void array_contains:
Prints if String array contains the String element
public static int search_value:
Search the value from the array
public static int findElement:
return the value based on if the element exists in the String array
public static int findElement_loc:
return the value based on if the element exists in the String array
public static void element_count:
return the number of the specific element provided by the parameter that appears in the array
public static int countElement:
return the number of specific elemet appearing in the String array
public static int[] change_size_of_array:
return the new array with all the values from original array but with different size
public static String[] change_size_of_array:
return the resized array with all the elements from the original array and deleted the specific value when it is in delete mode and return the resized array with one additional empty position at specific location the user required to insert new element
public static int[] insert_element:
return the new array with all the values from original array and additional value using change_size_of_array method
public static String[] insert:
return the new array with the new element inserted using change_size_of_array
public static int[] selection_sort_array:
return the sorted array of the original array
public static int largest_element:
return the largest number in array
public static int findLargest:
return the largest value based on the alphabetical order
public static int smallest_value:
return the smallest number in array
public static int findSmallest:
return the smallest value based on the alphabetical order
public static int[] delete_element:
return the new array with all the values from original array and the selected value deleted using change_size_of_array method and search_value method
public static String[] removeElementByItem:
return the new array with the element deleted from the original array using change_size_of_array
public static int[] make_copied_array:
return the new array with all the values from original array
public static String[] duplicateArray:
return the new copied array
public static boolean identical:
return true when two arrays are identical to each other and if not, return false
public static boolean sameArray:
return true when two String arrays are identical to each other, and false when two arrays are different from each other
public static String[] reverse:
return the new String array with the location of the elements are reveresed

Method Detail

makeArray

Method Summary Parameters Return
public static int[] makeArray:
Creates the new integer array and return created array
int array_size:
The size of the array the user want to create
Created int type array with Parameters

createEmptyStringArray

Method Summary Parameters Return
public static String[] createEmptyStringArray:
Creates the String array and return created array
int array_size:
The size of the array the user want to create
Created String type array with Parameters

user_defined_array

Method Summary Parameters Return
public static int[] user_defined_array:
Creates the new integer array with user defined values and return the array using makeArray method
NA
Created int type array with value that user entered

user_defined_array

Method Summary Parameters Return
public static String[] user_defined_array:
Creates the new String array using createEmptyStringArray and fill with user defined values and return the array using makeArray method. Print the log into the filePrintWriter myOutputAllow the program to print to external file

Created String type array with value that user entered, and print all the logs into the file

random_array

Method Summary Parameters Return
public static int[] random_array:
Creates the new integer array with random values and return the array using makeArray method
NA
Created int type array with random value

print_array

Method Summary Parameters Return
public static void print_array:
Print the values of integer array from parameter
int[] array:
The array the user wants to print to the screen and file
Created int type array with value

printArray

Method Summary Parameters Return
public static void printArray:
Prints the String array from parameter
String[] array:
The String array that is being required to printPrintWriter myOutputAllow the program to print to external file
N/A

array_contains

Method Summary Parameters Return
public static void array_contains:
Prints if String array contains the String element
String[] array:
The String array that is being searched from
String element:The String element that the method is looking for in the arrayPrintWriter myOutputAllow the program to print to external file
N/A

search_value

Method Summary Parameters Return
public static int search_value:
Search the value from the array
int[] array:The array looking for the valueint target:The value that the program is looking forboolean mode:Select if the user wants to print out every log or not
if the value exists in the array, return the location and if not, return -1

findElement

Method Summary Parameters Return
public static int findElement:
return the value based on if the element exists in the String array
String[] array:
The String array that is being searched from
String element:The String element that the method is looking for in the array
return 1 if the element exists, and return -1 if the element does not exists

findElement_loc

Method Summary Parameters Return
public static int findElement_loc:
return the value based on if the element exists in the String array
String[] array:
The String array that is being searched fromString element:The String element that the method is looking for in the array
return the index of the element's location if the element exists in the array, and return -1 if the element does not exists

element_count

Method Summary Parameters Return
public static void element_count:
return the number of the specific element provided by the parameter that appears in the array
int[] array:The array looking for the valueint target:The value that the program is looking for
return the number of the element appears in the array

countElement

Method Summary Parameters Return
public static int countElement:
return the number of specific elemet appearing in the String array
String[] array:
The String array that the program is counting the number of appearance fromString target:
The String element that the program is looking for in the String array
return the number of the String element appearing in the String array

change_size_of_array

Method Summary Parameters Return
public static int[] change_size_of_array:
return the new array with all the values from original array but with different size
int[] original_array:The original array that the program is resizingint operation:Decides if the program is expanding the size or making it smallerint hole:Set the location of the empty spot when the program is expanding the size of the array
return the new array that is resized from the original array

change_size_of_array

Method Summary Parameters Return
public static String[] change_size_of_array:
return the resized array with all the elements from the original array and deleted the specific value when it is in delete mode and return the resized array with one additional empty position at specific location the user required to insert new element
String[] original_array:
The original String array that the program is resizingin operation:
The operation that the program is operating (insert or delete)String target:
The String element that the program is deleteing or inserting to the original arrayint hole:
The location that the program is inserting the new element to original array
return the new String array with the elements that the user required to have

insert_element

Method Summary Parameters Return
public static int[] insert_element:
return the new array with all the values from original array and additional value using change_size_of_array method
int[] array:The original array that the program is inserting the value toint target:the value that the program is inserting to the arrayint index:The location that the program is inserting the value into the array
return the new array with the value inserted to the original array

insert

Method Summary Parameters Return
public static String[] insert:
return the new array with the new element inserted using change_size_of_array
String[] array:
The String array that the program is inserting the element toStrin target:
The String element that the program is inserting to the arrayint location:
The index that the program is inserting the element into arrayPrintWrite myOutput:
The PrintWriter element that allows the method to output to the external file
return the new String array with the element inserted to the original array

selection_sort_array

Method Summary Parameters Return
public static int[] selection_sort_array:
return the sorted array of the original array
int[] array_original:The original array that the program is sorting using the values using selection sort algorithmboolean respond_option:select if the program is printing the log of the operation or not
return the sorted array

largest_element

Method Summary Parameters Return
public static int largest_element:
return the largest number in array
int[] array:The array that the program is looking for the largest value
return the maximum value in the array

findLargest

Method Summary Parameters Return
public static int findLargest:
return the largest value based on the alphabetical order
String[] array:
The String array that the program is searching the largest value
return the index of the largest element of the array

smallest_value

Method Summary Parameters Return
public static int smallest_value:
return the smallest number in array
int[] array:The array that the program is looking for the smallest value
return the minimum value in the array

findSmallest

Method Summary Parameters Return
public static int findSmallest:
return the smallest value based on the alphabetical order
String[] array:
The String array that the program is searching the smallest value
return the index of the smallest element of the array

delete_element

Method Summary Parameters Return
public static int[] delete_element:
return the new array with all the values from original array and the selected value deleted using change_size_of_array method and search_value method
int[] array:The original array that the program is deleting the value fromint target:the value that the program is deleting from the array
return the new array with the value deleted to the original array

removeElementByItem

Method Summary Parameters Return
public static String[] removeElementByItem:
return the new array with the element deleted from the original array using change_size_of_array
String[] array:
The String array that the program is deleting the element fromStrin target:
The String element that the program is deleting from the arrayPrintWrite myOutput:
The PrintWriter element that allows the method to output to the external file
return the new String array with the element deleted to the original array

make_copied_array

Method Summary Parameters Return
public static int[] make_copied_array:
return the new array with all the values from original array
int[] array:The original array that the program is copying the value from
return the new array with the identical value copied from the original array

duplicateArray

Method Summary Parameters Return
public static String[] duplicateArray:
return the new copied array
String[] array:
The String array that the program is duplicating from
return the new String array with duplicated size and values from the original array from the parameter

identical

Method Summary Parameters Return
public static boolean identical:
return true when two arrays are identical to each other and if not, return false
int[] array1:The first array that the program is comparingint[] array2:The second array that the program is comparing
return true when two integer arrays are identical and if not, return false

sameArray

Method Summary Parameters Return
public static boolean sameArray:
return true when two String arrays are identical to each other, and false when two arrays are different from each other
String[] array1:
The frist String array that the program is comparingString[] array2:
The second String array that the program is comparing
return true value when two String arrays are identical, and false if they are not identical

reverse

Method Summary Parameters Return
public static String[] reverse:
return the new String array with the location of the elements are reveresed
String[] array:
The String array that the program is reversing the elemets' locationPrintWriter myOutput:
Allow the program to print to external file
return the new String array with the elemets' location in the array reversed