Java to determine whether the values in an array are consecutive adjacent methods, java Array
* Determine whether the values in an array are consecutive adjacent.
* The following conditions are met:
* 1.0 is an exception, where 0 can be used with any character.
* 2. identical values are not repeated.
* 3. The array can be out of order.
* If the array does not contain 0, the maximum value-Minimum value = n (array length)-1 is met.
* When the array contains 0, the maximum value and minimum value are met. <n (array length)-1
* Therefore, when the maximum value-Minimum value> n (array length)-1, it must not be a consecutive adjacent array.
Package datastruct. usearray; public class JudgeAdjacent {private static boolean judege (int a []) {int min = Integer. MAX_VALUE; int max = Integer. MIN_VALUE; for (int I = 0; I <. length; I ++) {if (a [I]! = 0) {if (min> a [I]) {min = a [I];} if (max <a target = "_ blank">. length-1) {return false;} else {return true;} public static void main (String [] args) {int a [] =, 0, 0}; if (judege (a) {System. out. println ("this array is adjacent! ");} Else {System. out. println (" this array is not adjacent! ") ;}}</A>
The above java method to determine whether the values in an array are consecutively adjacent is all the content shared by the editor. I hope to give you a reference, and I hope you can provide more support to the customer's house.