Create a method public static int distance( int[] all, int x ). The distance method returns the smallest number of elements in the all array between two elements that both contain the value x. If the field has less than 2 elements or the value x does not occur at least twice, an exception is thrown. If the value x is in two consecutive elements, 0 is returned. The all field must not be changed when executing the distance metho
Create a method public static int distance( int[] all, int x ).
The distance method returns the smallest number of elements in the all array between two elements that both contain the value x. If the field has less than 2 elements or the value x does not occur at least twice, an exception is thrown. If the value x is in two consecutive elements, 0 is returned.
The all field must not be changed when executing the distance metho
public static int distance int[] all, int x) { if ( all length > 1) { } else { throw new IllegalStateException(); } }
Create a method public static int distance( int[] all, int x ). The distance method returns the smallest number of eleme
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am