[Question]how to count the occurance of numbers inside the array

im just practicing my java skill but i cant get my program work can you give me guys some idea on how to determine a number that occured more than 1 inside the array e.g i have 10 elements and inside of my offset i have
1,2,5,4,5,6,5,8,9,5
and what im planning to do is count the occurances of the number who occures more than 1 and for that 5 occur 3 times how my program can know that i use for loop but cant figure out how to filter the occurances of numbers inside
my offset
thank's

Encephalopathic you said put - 1 instead i did - 2
public class sample
   public static void main(String args[])
      int num[] = {2,2,2};
      int index1, count = 0, find = 0;
      for(index1 = 0; index1 < num.length - 2; index1++)
         for(int index2 = 0; index2 < num.length; index2++)
            if(num[index2]==num[index1])
              find = num[index2];
              count++;
         System.out.println("i found " + find + " " + count + " same number inside your offset");
}output is:
i found 2 3 same number inside your offset
but another question is what if i want my program to tell the other number that occur 1 time
like this:
i found 1 2 same number inside your offset
i found 2 0 same number inside your offset
i found 1 2 same number inside your offset

Similar Messages

  • How can I get the phone numbers in contacts to appear with dashes between the first 3 numbers, the next 3 numbers, and the last 4 numbers?  Until very recently it did so.  Contacts on my macbook pro does show up this way.  I do have a mobile me account an

    How can I get the phone numbers in contacts to appear with dashes between the first 3 numbers, the next 3 numbers, and the last 4 numbers?  Until very recently
    it did so.  Contacts on my macbook pro does show up this way.  I do have a mobile me account and in the past syncing was no problem.  What setting has changed?

    The phone number format as well as the date language and format and the time format are controlled by the Region Format setting. Go to Settings > General >International > Region Format.  When you change a region format, you can go back one page (to International) and see an example of the date/time/phone number format that your selected region format will produce.

  • How can we view the error message numbers in the web ui?

    Dear all,
    How can we view the error message numbers in the web ui? It gives the error but no number.  It is possible to debug in web UI so how can we accomplish this?
    Thanks,
    FK

    Hi  Fakhan,
    You can absolutely do that.
    Check the class: CL_BSP_MESSAGES
    Also if you want to find out the exact Message Class and Message Number, go to table T100, type text in field TEXT, you will get Message Class and Message number in fields ARBGB and MSGNR respectively.
    I hope this helps.
    THanks
    Vishal

  • How can I drag contacts into numbers like the old version?

    How can I drag contacts into numbers like the old version?

    Copy and paste works.  But drag and drop is also back in version 3.2. It works well here. Just drag and drop onto the canvas.Make sure you've upgraded to version 3.2 as earlier versions of Number 3 did not support drag and drop from Contacts.
    Note that the column headers are misaligned if you are dragging contacts that do not contain an image.  But the information in the body of the table drags in correctly.
    SG

  • I forgot my Apple ID password and the birthday but I remember my security questions how can I know my password (I know the security questions)

    I forgot my Apple ID password and the birthday but I remember my security questions how can I know my password (I know the security questions)

    I'm curious how you forget your own birthday?
    dodidoid wrote:
    I forgot my Apple ID password and the birthday
    you can try here first:
    iforgot.apple.com
    https://iforgot.apple.com/password/verify/appleid
    or
    Contacting apple id support
    http://www.apple.com/support/appleid/contact/

  • HT4623 I down loaded ios 7 to my wifes ipad 2  but because of the streamlined look my wife can bearly see the letters and numbers on the key board because of an eyesight problem  She had no problem with the old keyboard.  Is there a way to make the letter

      I downloaded ios 7 to my wifes ipad 2.  The only problem was, with the new system the letters and numbers on the keyboard became so streamlined that my wife had trouble seeing them because of a eye problem.  Is there a way to get the old keyboard back and if not how do you uninstall ios 7?

    I had thought this situation was solved but it just got worse. In addition to being without service for several days I am now being charged  a cancellation fee for a broadband service that BT disconnected in error. BT Vision was also terminated by BT but the set up charges are still in place. Does anyone know who the relevant Ombudsman is? I called BT from America on Friday - for an hour - while someone called Aruj sorted out why there is an order 'in progress' that I didn't initiate; why I have fees relating to a problem created by BT and why there are references to a house move that didn't take place and a BT Vision service I no longer have but didn't cancel myself. He assured me it would be rectified and my bill would be reduced by 139 pounds and we would get confirmation of this later that day. I asked him what chance there was that this would not actually happen - he said no chance at all; my new bill would be 23.50.
    There was no text message. An online chat person today told me there had been a fee reduction request which had been declined and there was nothing else he could help me with as he dealt only with broadband. But he would get BT Vision to email me. They always seem so helpful.............
    I'm sure I'm listed somewhere as 'a problem', there's no other explanation for why I get the runaround

  • In iOS 7 you can still make calls from the locked screen. Just swipe the missed call numbers to the right. Is this a bug?

    In iOS 7 you can still make calls from the locked screen. Just swipe the missed call numbers to the right. Is this a bug?

    How is it a security breach? You're free to turn off lock screen notifications for the phone app so that no one can do that.... even if they can, they can only call the number that called you... nothing else. (well, except for 900 or whatever the emergency services number is where you are, but that's required by law).

  • How do I create a duplicate image inside the same page? Then how do I change the color of that image

    how do I create a duplicate image inside the same page? Then how do I change the color of that image from black to red?

    Hello there!
    Here is one way to create a duplicate image and colorize it. As you can see below, I have one image right now, that I want to duplicate.
    My layers panel looks like below.
    To duplicate your image, click the downward arrow on the right side of your Layer Panel.
    Select Duplicate Layer. This will duplicate the layer that the image is on.
    Select "OK" to approve the duplication.
    As you can now see in the Layers panel, the image is duplicated. The new layer is now at the top of the Layer panel.
    Now to colorize your image, go to Window > Adjustments.
    The Adjustments panel will now be opened. Select the Hue and Saturation icon as seen circled in red.
    The Hue and Saturation propertied panel will be opened. I selected "Colorize", and adjusted the hue and saturation bar to achieve the level red in my photo.
    As you can see below, the image is now red.
    Now i want to make sure only ONE of my image layers is red. I moved the Hue and Saturation layer to only be on top of the bottom layer. The image on the top layer now will not be affected by the red.
    Select the move tool, so I can now move the image layers so we can see both of them.
    With each image layer selected, you can take the move tool and move the images. I moved mine on top of eachother and you can see my red layer (bottom) and the non red layer (top).
    I hope that helps. i have also included helpful links.
    Please post back with any questions,
    Janelle

  • When e mail a photo from my mac in i photo and receiving on the i pad the photo appears the same as the other ones i send but the jpg file numbers are the same

    when using  e mail from my i photos on the mac and attach a photo  and receiving on the i pad the photo appears the same as the other ones i send but the jpg file numbers are the same

    I have one album named "iPad". I don't recall how it got there, where it is there by default or if I created it. Nothing in this album shows a trash can in either full or thumbnail view - I can only edit or share or add to.
    In full view mode, when I click on "edit" the upper left shows "cancel". The other greyed out options next to "cancel" are "undo" and "revert to original".  The bottom shows the usual photo editing tools, but no "edit". Most of the other pictures show the trash can, which is located on the bottom right corner in camera roll in full view mode. In thumbnail mode when I click "select" on the upper right corner and choose a photo the trash can appears on the upper left corner". This all seems normal. However, the "iPad" album behaves different.

  • How do you take out the quarter sized battery inside the computer?

    How do you take out the quarter sized battery inside the computer?

    Hi,
    We do not know your computer therefore can not say how. In general, open the case, locate it (RTC or CMOS battery), disconnect cables (if any) and pull it out.
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • May I know how to change the color of texts inside the indicator box?

    Can anyone tell me how to change the color of texts inside the indicator box? I have tried to use property node but not really know how it functions.
    In fact, I am writing a program for which the number inside indicator on front panel will show red color if the measured value can't reach the requirement. I am using LabView 6.1 Professional
    Thank You for your attention!!!!!!

    Simply use a property node with "NumText.TextColor" and wire the correct color depending on your test result.
    The attached simple example (LV 6.1) lets you change it from the front panel. In your case, you would use your test output instead of a FP switch, of course. Message Edited by altenbach on 05-25-2005 09:05 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    TextColor.vi ‏18 KB

  • Want to get the Last 4 numbers of the Class number  of Material   !!Urgent!

    Hi all,
    I am having a BAPI called BAPI_OBJCL_GETCLASSES to get CLASS NUMBER FOR MATERIAL. In that I am getting the Class number for the Material.
    But in that matetial  I want to get only the last 4 numbers of the Class number,
    Can any one tell me is there any FM to solve this  or any other way to do.
    Your help will be greatly appreciated
    Regards
    Yathish

    Hi,
    Try the following code after BAPI_OBJCL_GETCLASSES.
    If you are not getting the full number(means class no is 18 char long & suppose a class no is '100000') then you can calculate last four digits manually using the following solution. Declare a variable of type string & assign the number(ALLOCLIST-CLASSNUM) to variable. Then use following function module STRING_REVERSE & pass the variable. And declare another variable of length 4 & assign the value like this:
    v_var = v_str+0(4).
    Again pass the v_var to STRING_REVERSE.
    If you are getting nuumber with leading zeros (eg '000001000000000000') then go swains solution.
    like this: (Write this code after BAPI_OBJCL_GETCLASSES)
    V_var = ALLOCLIST-CLASSNUM+14(4).
    Ashven

  • How to copy/access a string from inside the driver

    is there any equivalent to strncpy() to use inside
    the driver for copying user sent data to local buffer .
    i used I_STRioctl and assigned struct to strioctl.ic_dp
    as shown below..
    char * buf;
    struct user-data
    int minor;
    char* data;
    struct user_data u_data;
    buf="hello world"
    u_data.minor=0;
    u_data.data=buf;
    strioctl.ic_dp=&u_data;
    strioctl.ic_len=sizeof(struct user_data);
    ioctl(fd,I_STR,&strioctl);
    when i tried to copy/access the string sent by the user application from inside the driver, machine gets into
    booting ...
    here what i did was
    in wput routine
    struct user_data *u_data;    
    u_data =(struct user_data*)mp->b_cont->b_rptr;      
    cmn_err(CE_NOTE,"minor= %d",u_data->minor);
    till here working well..
    where as..
    cmn_err(CE_NOTE,"data= %s",u_data->data);
    causing panic to the system...booting happens.
    please help me out ..
    thank u all
    ss vasu

    looks like the data pointed to by 'data' is not copied from user space to kernel space.
    u_data.data=buf, just makes pointer assignment, does not copy data pointed to by buf.
    two solutions:
    1. Declare data as a array(char data[10] or something
    2. Copy buf after the structure and point data to it. strioctl.ic_len should be set to sizeof(struct) +
    data size.
    -Vijay
    is there any equivalent to strncpy() to use inside
    the driver for copying user sent data to local buffer
    i used I_STRioctl and assigned struct to
    strioctl.ic_dp
    as shown below..
    char * buf;
    struct user-data
    int minor;
    char* data;
    struct user_data u_data;
    buf="hello world"
    u_data.minor=0;
    u_data.data=buf;
    strioctl.ic_dp=&u_data;
    strioctl.ic_len=sizeof(struct user_data);
    ioctl(fd,I_STR,&strioctl);
    when i tried to copy/access the string sent by the
    user application from inside the driver, machine gets
    into
    booting ...
    here what i did was
    in wput routine
    struct user_data *u_data;
    u_data =(struct user_data*)mp->b_cont->b_rptr;
    r;
    cmn_err(CE_NOTE,"minor= %d",u_data->minor);
    till here working well..
    where as..
    cmn_err(CE_NOTE,"data= %s",u_data->data);
    causing panic to the system...booting happens.
    please help me out ..
    thank u all
    ss vasu

  • Has Apple stopped installing the liquid contact indicator inside the SIM slot opening on the 6 & 6+?  I've inspected several devices and they are not installed.

    Has Apple stopped installing the liquid contact indicator inside the SIM slot opening on the 6 & 6+?  I've inspected several devices and they are not installed.

    I don't know that Apple has ever officially commented on such things, one way or another. Places like ifixit will be your best sources for such information - https://www.ifixit.com/Answers/View/200937/How+many+water+indicators+or+sensors+ are+there+in+the+iPhone+6
    certainly none of us fellow users know what Apple's official current policies in such things are.

  • Is it legal to use the iPhoto slideshow video inside the third party iPad enterprise application?

    Hi,
       we are developing one enterprise application specifically for iPad.Kindly advise me is it legal to use the iPhoto slideshow video inside the third party iPad enterprise application (slide show with images)?
    Thanks in advance.

    Thanks Terence for your reply. I mean  for "the iPhoto slideshow video" is : I have collection of my own images , using iPhoto software i created a slideshow based on 'origami' theme and exported as a video file. Can I use that video in my enterprise iPad application?
    Thanks.

Maybe you are looking for

  • Handling Unit - Storage Location

    Hi,   Finished product is lying against sales order in a particualr storage location eg: 1000  . Is it possible to create handling unit through Outbound delivery in the same storage location . If it is possible is it the right method to do. Awaiting

  • Audiodock not showing in patchmix

    hi ; I just pluged in my audiodock in my 1010 card ; it seems to power up ; it responds when I change the clock in patchmix, the light switches on the dock ; the problem is that patchmix is not showing the audiodock as connected (stays grey ; will no

  • Any certification for OIM?

    Hi, Could somebody inform me if any Certification is available on Oracle Identity Manager*? I would like to get certified by Oracle, in case such certification is available on OIM. Thanks. Edited by: 796705 on Sep 29, 2010 11:04 PM

  • In itunes i don't see the possibility to synchronise the agenda from the pias

    In Itunes I don't see the possibility to synchronise the agenda from the Ipad anymore. What can I do

  • OSB http headers management

    I have a scenario where my osb messages are rejected by the target server, while the same messages are accepted when sent by wget. The only difference between the two requests is represented by the http headers. The first thing to notice was that mos