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

1 Expert Approved Answer
Step: 1 Unlock

public int countDuplicates int count ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!