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

  • Home
  • SEARCH
  • 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 6997459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:17:10+00:00 2026-05-27T20:17:10+00:00

i have two integer array, each size 95700.i want compare to two integer arrays,i

  • 0

i have two integer array, each size 95700.i want compare to two integer arrays,i got maximum size of integer using Integer.MAX_VALUE(2147483647).

i used following code,

for(int i=0;i<array1.length;i++) {
    if (array1[i] == 0xFF0000FF && array2[i] == 0xFFFFFFFF) {
        matched++;              
    } else {
        unMatched++;
    }
}

this code taking lot of time(50s). How to decreases comparison time…please help me

EDIT:
this is my logcat:

12-22 15:20:29.638: INFO/System.out(1660): start time-----18041173568804 
12-22 15:20:29.638: INFO/System.out(1660): time-----40981116222 
12-22 15:20:29.688: INFO/System.out(1660): The array comparison toook an average of 40.981116 second
  • 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-05-27T20:17:11+00:00Added an answer on May 27, 2026 at 8:17 pm

    You need to provide more detail because there is no way the array comparison is taking 50 seconds, or even 50 milli-seconds as described

    public static void main(String... args) {
        int[] array1 = new int[95700];
        int[] array2 = new int[95700];
        for (int j = 0; j < array1.length; j += 3) {
            array1[j] = 0xFF0000FF;
            array2[j] = 0xFFFFFFFF;
        }
        long start = System.nanoTime();
        int runs = 10000;
        int matched = 0, unMatched = 0;
        for (int r = 0; r < runs; r++) {
            matched = unMatched = 0;
            for (int i = 0; i < array1.length; i++) {
                if (array1[i] == 0xFF0000FF && array2[i] == 0xFFFFFFFF) {
                    matched++;
                } else {
                    unMatched++;
                }
            }
        }
        long time = System.nanoTime() - start;
        System.out.printf("The array comparison to an average of %.6f second, matched=%,d, unmatched=%,d%n",
                time / 1e9 / runs, matched, unMatched);
    }
    

    prints

    The array comparison to an average of 0.000109 second, matched=31,900, unmatched=63,800
    

    That is one tenth of one milli-second.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two arrays (a and b) with n integer elements in the range
I have two applications written in Java that communicate with each other using XML
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have the following two dimensional array in my java program. Integer[][] arrayOfSets =
Suppose I have two arrays: val ar1 = Array[String](1, 2, 3) val ar2 =
In a two dimentional integer space, you have two points, A and B. This
I have two maps of type Map<Long, Integer>, one named oldValues representing the old
Let's say I have two simple models project t.string :title vote t.references :project t.integer
if i have two hashmaps, of types HashMap<Integer, HashMap<Integer, Police>> time_id_police; HashMap<Integer, HashMap<Integer, Ambulance>>

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.