Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9207565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:24:56+00:00 2026-06-18T00:24:56+00:00

I have a arraylist of type integer. The list contains some values. At some

  • 0

I have a arraylist of type integer. The list contains some values.
At some point the list will contain similar values consecutively (3 values).
I need to find the position at which the 3 similar elements appear.

For example:

ArrayList<Integer> int_values=new ArrayList<Integer>();
int_values.add(10);
int_values.add(20);
int_values.add(30);
int_values.add(10);
int_values.add(10);
int_values.add(10);

As can be seen from position 3 to 5 there are similar values.
So I need to retrieve the position 5.
Also this series of similar elements repeating will occur only once.

I hope I am able to explain the scenario.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:24:57+00:00Added an answer on June 18, 2026 at 12:24 am

    You can do as below,

    public static List<Integer> findConsequtive3(ArrayList<Integer> int_values) {
    
            Integer[] arrayItems = (Integer[]) int_values.toArray(new Integer[0]);
    
            List<Integer> consequetive = new ArrayList<Integer>();
            int count = 1;
            for (int i = 1; i < arrayItems.length; i++) {
                if (arrayItems[i - 1] == arrayItems[i]) {
                    count++;
                    if (count == 3) {
                        consequetive.add(i + 1); // Since array is zero indexed adding 1
                        count = 0; // resetting count
                    }
                }
            }
            return consequetive;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 2D List of type Integer ( ArrayList< List < Integer >
I have an arraylist that gets different type of values in it, 1st value->
I have a list (an ArrayList , infact) of type HColumn<ColName, ColValue> . Now
I have; List<String> stringList = new ArrayList<String>(); List<Integer> integerList = new ArrayList<Integer>(); Is there
I have a List of HashMap 's which has key of type Integer and
I have list of files stored inside arraylist that I need to download in
I have some ArrayList s declared. Some of them are ArrayList<Integer> and other are
If i have an ArrayList of type Integer, containing numbers like 1,3,4,9,10 etc... How
I have a list of type List<Iterable<Object>> and in some case the objects that
I have an ArrayList of type modules, each module has an arraylist of Assignments.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.