Question: Write a method called hasTwoConsecutive that returns whether or not a list of integers has two adjacent numbers that are consecutive integers ( true if
Write a method called hasTwoConsecutive that returns whether or not a list of integers has two adjacent numbers that are consecutive integers ( true if such a pair exists and false otherwise). For example, if a variable list stores the values [1, 18, 2, 7, 8, 39, 18, 40], then the call list.hasTwoConsecutive() should return true because the list contains the adjacent numbers ( 7, 8 ), which are a pair of consecutive numbers.
Step by Step Solution
3.54 Rating (157 Votes )
There are 3 Steps involved in it
public int countDuplicates int count ... View full answer
Get step-by-step solutions from verified subject matter experts
