How remove duplication in the array

import java.util.*;
public class stringlength{
     public static void main(String[] args){
          String p = "i love java very much.but i like it";
          String t = "i love java very much.but i like it";
          String[] sentence1 = p.split("\\.");
          String[] sentence2 = t.split("\\.");
          String[] EachLine1;
          String[] EachLine2;     
//*******Begin break the paragraph into line p and t****************
          for(int line1_p = 0 ; line1_p < sentence1.length ; line1_p++){
                    EachLine1 = sentence1[line1_p].split(" ");          
               for(int line2_t = 0 ; line2_t < sentence2.length ; line2_t++){
                    EachLine2 = sentence2[line2_t].split(" ");
          //************End of break line*************************************
          //************Begin compare each word********************************
                    for(int word_p = 0 ; word_p < EachLine1.length ; word_p++){          
                         for(int word_t = 0 ; word_t < EachLine2.length ; word_t++){
                              if(EachLine2[word_t].equals(EachLine1[word_p])){
                                   System.out.println(EachLine1[word_p]);
                         if(count>6){     // set the size that want to match
                                             cost++;
          //*************End of compare*****************************************
the above is my coding.
well i wan compare the 2 string..then if found matched...print out the match word.
from the comparison, it will create duplication during the matching.
so i wan remove all the duplication word by only print out the match result.
thx guys.....:)

well i found out the solution from the example already.
but that one is for single array...
now i want to compare 2 string together but when i found the matched word...it cannot remove the duplication words..
anyone can help me to solve this problem?
it is very urgent..!!
import java.util.*;
public class FindDups {
    public static void main(String args[]) {
         String a ="i came i saw i left left left";
         String b ="i came i saw i left left left";
         String[] c=a.split(" ");
         String[] d=a.split(" ");
         for(int i=0;i<c.length;i++){
              for(int j=0;j<d.length;j++){
                   if(c.equals(d[j])){
               String[] e=d[j].split(" ");
               ArrayList aList;
                    aList = new ArrayList( Arrays.asList(e ) );
          HashSet s = new HashSet( aList ); // create a HashSet     
          System.out.println(" distinct words detected: "+s);

Similar Messages

  • How remove fan on the chipste

    Hello !
    First of all please excuse me for my poor english, that's not my native language.
    I have a KT3Ultra-ARU who worked very fine until its chipset's fan made strange sounds. So I bought a new ofan for my chipset.
    And there I have a big big newbie's problem : how can I remove the silver thing which is between the fan (that I removed) and the chipset ? How can I have access to chipset ?
    I tried to remove the silver thing, but it doesn't work. It seems to be fixed with something.
    Could you please help me ? It would be very nice.

    not really
    its not hard ,there are 2x plastic pins hold it on
    then after you remove them it will seem stuck
    but its just the suction from the cooler grease under it
    http://us.st7.yimg.com/store1.yimg.com/I/directron_1802_453190943
    that shows 2x similar black pins with springs on
    they work like a rawl plug you fix things to a wall
    by opening up

  • How copy part of the array buffer from ColorFrame

    I want copy part of the color frame When I receive it.
    Is there way to do that without copy all the byte array first? (+ example)
    (Question similar to Kinect 1,
    but for kinect 2)

    if you access the raw data you can set offsets based not he width/height of the color frame(y*width+x). The c++ and managed api provide that as a function of the frame. These api's are used in some of the samples so review the code if you are
    unsure of the api use:
    c++ AccessRawUnderlyingBuffer
    https://msdn.microsoft.com/en-us/library/microsoft.kinect.kinect.icolorframe.accessrawunderlyingbuffer.aspx
    .Net c# - LockRawImageBuffer
    https://msdn.microsoft.com/en-us/library/windowspreview.kinect.colorframe.lockrawimagebuffer.aspx
    Carmine Sirignano - MSFT

  • How can I get the size of conatiner which is kept in the array of conatiner?

    I have created an Array of Conatiner in Local variable (say Locals.Array_C). Within Array_C, I have few containers like Cont_1, Cont_2, Cont_3.
    Lets consider that there are four(4) Number fields added in the Cont_2.
    Here the number of elements in the Cont_2 is 4, but if I want to read this size through TestStand, how can I do that?
    I also tried to use "Call PropertyObject.GetNumElements" ActiveX property, but I could not get how to set Object Refernce in this case.
    Please help.
    Solved!
    Go to Solution.
    Attachments:
    Locals.Array_C.JPG ‏67 KB

    Hi,
    Your problem is how you are specify the array part. It may also be what you are using as the reference.
    Lets look ate the array part using the SequenceContext as the reference. The lookup string will be:
    "Locals.Array_C[1].Cont_2.Elemen4"
    If you are using the Locals as the reference the lookup string will be:
    "Array_C[1].Cont_2.Element4"
    Hope this helps
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Removing movie clips in arrays

    Hi there
    I have this code in my Flash file:
    for(bubble in bubbleArray){
         bubbleArray[bubble]._y -= 3;
         if(bubbleArray[bubble]._y < 370){
              bubbleArray[bubble].removeMovieClip();
    I'm wondering, when I remove the movie clips should I also be popping them from the array?
    I have an onEnterFrame function that attaches the movie clips and pushes them into the array, so I'm worried that if I don't pop them the array will continue to increase in size and slow down the movie. Is this the case, or will they be automatically removed from the array by the removeMovieClip() method above?

    Looks like I spoke too soon. I imagined that removing them from the array would be easy, but I'm struggling.
    The movie clip that is removed from its parent clip and should be removed from the array will not always be the first element in the array, and I'll need to remove multiple clips at a time. I've put in a trace action to trace the length of my array, and after about ten seconds it contains about 2500 elements, most of which have already been removed using the removeMovieClip() method. I'm worried this will slow down the movie.
    So to clarify: How can I remove these elements from my array when I remove them from the stage?
    I tried to include something like:
    while(bubbleArray[0] == undefined){
         bubbleArray.shift();
    but it caused Flash Player to freeze up. Also, if I trace bubbleArray[0] it is only "undefined" before something is pushed into the array. Once the clip has been removed from the stage, the trace just returns a blank line, not "undefined".
    I'd appreciate any help.
    Here is all my code:
    stop();
    splash.stop();
    var i:Number;
    var j:Number = 0;
    var minBubbles:Number = 10;
    var maxBubbles:Number = 20;
    var bottomBubbleLimit:Number = 0;
    var topBubbleLimit:Number = 1;
    var bubbleNumber:Number;
    var bubbleX:Number;
    var bubbleY:Number;
    var bubbleScale:Number;
    var bubbleMinScale:Number = 30;
    var bubbleMaxScale:Number = 100;
    var fewerBubbles:Number;
    var ring:String;
    var ringArray:Array = [ringAnimation.ring1, ringAnimation.ring2];
    var bubbleArray:Array = [];
    ringAnimation.onEnterFrame = function(){
        for(ring in ringArray){
            if(ringArray[ring]._y > 370){
                bubbleNumber = (minBubbles + (Math.random() * (maxBubbles - minBubbles)));
                for(i = 0; i < bubbleNumber; i++){
                    bubbleX = ((ringArray[ring]._x - (ringArray[ring]._width / 2)) + (Math.random() * ringArray[ring]._width));
                    bubbleY = ((ringArray[ring]._y - (ringArray[ring]._height / 2)) + (Math.random() * ringArray[ring]._height));
                    bubbleScale = bubbleMinScale + (Math.random() * (bubbleMaxScale - bubbleMinScale));
                    ringAnimation.attachMovie("bubble", "bubble" + String(j), this.getNextHighestDepth(), {_x:bubbleX, _y:bubbleY, _xscale:bubbleScale, _yscale:bubbleScale});
                    bubbleArray.push(ringAnimation["bubble" + String(j)]);
                    j++;
        for(bubble in bubbleArray){
            bubbleArray[bubble]._y -= 3;
            if(bubbleArray[bubble]._y < 370){
                bubbleArray[bubble].removeMovieClip();
        trace(bubbleArray.length);
        if(ringAnimation._currentFrame == 6){
            splash.gotoAndPlay(1);
        }else if(ringAnimation._currentFrame == 12){
            splash.gotoAndPlay(1);
    fewerBubbles = setInterval(reduceBubbles, 600);
    function reduceBubbles(){
        if(minBubbles > bottomBubbleLimit){
            minBubbles--;
        if(maxBubbles > topBubbleLimit){
            maxBubbles--;
        if(minBubbles == bottomBubbleLimit && maxBubbles == topBubbleLimit){
            clearInterval(fewerBubbles);

  • How to adjust a "control array" size

    I have a program that creates a digital PWM signal with variable duty cycle. The duty cycle changes every 50 ms, but the overall wave frequency stays at a frequency determined by the user. I have the VI attatched.
    My problem is this...I need to be able to control the overall cycle time. This means the size of my array of duty cycles needs to adjust based on the cycle time (i.e. a cycle time of 1 second would require 20 of the 50 ms slots, while a 1.3 second cycle would need 26).
    I currently have only 4 slots in my array, meaning the total cycle time is .2 s. I understand how to manually add and remove elements to the array, but I can't figure out how to add a control to it so that the array size changes automatically, allowing much quicker entry of data. As of now I can make it work, it just takes super long to add or delete array elements. The ideal situaton would have a constant control for cycle time divided by 50 that would change the array size.
    I can't find any info on this, and I think I even saw a post asking that this kind of feature be added. I'm relatively new to this program.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    var_duty_cycle.vi ‏25 KB

    Currently, your VI is a one-shot deal. What you need is a state machine that updates the pct duty cycle array control as a function of the frequency while the current I/O code is idle.
    I would use an array of clusters, where each cluster contains e.g. a sequence number, a duty cycle, and a string as element label. Show the scrollbar and set the size whenever the relevant inputs change. Do you want to reset the current setting when the number changes or do you want to retain the current settings as much as possible? You could just use the existing values, reshape to the larger or smaller size, and write it back to the control via a local variable. Set all elements  except the percent to disabled so they act as indicators and cannot be changed by the user.
    (You also need to program around it if the operator tries to manually add more elements. A better solution would be this idea, so vote for it .)
    Some more general comments bout your code:
    Why do you use extended precision floating point. All your waits are internally just integers. EXT makes no sense
    There is a primitive for 1/x. However, you could just do a 1000/x and eliminate the multiplication afterwards. SInce you are dealing with integers, you can even do the division using quotient&remainder. Depending on the allowed frequency range there are possibly no orange data needed at all.
    Make the diagram constant representation match the rest of the code.
    The pulses/50ms indicator belongs before the loop. No need to recalculate and refresh it over and over from the same input values.
    LabVIEW Champion . Do more with less code and in less time .

  • How can i get a array from a JSP ?

    Hi all,
    i have a STORED PROCEDURE like this:
    static public void getMyArray(double [] xx) {
    for (int i=0; i<myarr.length;i++){
    myarr=3.145*i;
    xx=myarr;
    return ;
    how can i get the array with XSQL and transform with a XSL ?
    Is this at all possible?
    Thanks for any help.
    Achim

    u r asking how ca u get array from jsp?
    and u r asking xsql ...some stuff i couldnot understand .can u repeat the question properly?
    null

  • After an element in the array is removed, how to move the array up?

    Hi,
    My programs creates an array of strings. The user can choose to insert or delete a string. After a string has been deleted, I like to move the rest of the array up to fill up the space. For examples,
    String[] before={"This", "is", "a", "test"};
    After "a" is removed, instead of assign null to the space, I like to move "test" up so it becomes
    String[] after={"This", "is", "test", null};
    Can anyone help?
    Thanks.

    well i'm not doing your homework but the answer is three steps and two
    loops
    step one create a new array "after" one less than the size of your original "before".
    step two loop through the elements of "before" up to the element
    that was removed. add these elements to the "after" array.
    step three loop through the elements of "before" starting at the
    element after the one that was removed. add these elements to the
    "after" array.
    now when you get this done there is a better way to do this other than
    loops. use System.arraycopy() you can see the api for that here...
    http://java.sun.com/j2se/1.4/docs/api/java/lang/System.html

  • How to eliminate or remove zeros from 1D array

    How to eliminate or remove zeros from 1D array. Let say I have 1D array having foolowing elements
    "0 0 0 0 0 4 0 0 9 0 0 1 4 0 0 0 0 0 0 0 0 10 9 0 0"
    So after removing or eliminating zeros it will become as follow
    "4 9 1 4 10 9"
    So can any body guide me how can I do that? See attached Image for details.
    Thanks 
    JK

    altenbach a écrit :
    hchiam wrote:
    Here are 2 example .vi's I made based on altenbach's removeZeroes.png in this discussion thread: 
    It seems pretty pointless to post those because no new useful information is given.
    Currently, only the input is defined in the connector pane, making them useless as subVIs.
    unlike my example using integers, an "=0", like any "equal" comparison, is potentially dangerous with DBLs.
    Reshaping a 2D array to 1D before removing zeroes is pretty pointless because a 2D output cannot be recovered. A more interesting scenario would be to remove some columns or rows (e.g. that are all zeroes) from a 2D array.
    You should also clean up the front panel, e.g. properly zero the upper left corner, make the controls/indicators nicely labeled, sized and arranged, and maybe even add scrollbars to the arrays.
    Thank you for those comments.
    Now the input and output are defined (in the updated attachments) for use as example subVI's.  I also cleaned up a few visual details, but I leave the rest for others to cater to their specific uses if they don't want to use this as a subVI (or at least as-is), such as changing the icons or changing to integers instead of doubles.
    I'm not sure about what you mean exactly with "=0" being "potentially dangerous with DBLs".  I'm guessing you had a certain case scenario in mind.  Although the subVI's seem to work fine within my larger program and situation, my situation may not generalize with regards to this point.
    I reshaped from 2D to 1D, with a 1D output, because it could be helpful for things like when later processing just needs a 1D array.  For example, in my situation I had to remove a huge spike of unnecessary "0"'s from a previous subVI that were affecting the output display of a certain histogram.  So it turned out a 1D array output was helpful, and you never know what problems come up, so I included the 2nd example.
    Hopefully if someone is looking for this, they can just use or play with an example subVI (granted that they know how to plug things in for their context).  I was hoping to post a subVI people could put to direct use.

  • How to remove item from my array

    hi, I have one array with items. now I want to remove all items from array. How it can be possible ?

    You're welcome.
    I have noticed a few silly mestakes in my posts. You probably caught them, but just for clarity:
    1. yourArray.length without brackets ();
    2. < instead of <= in the loop conditions;
    3. when looping with pop() function, the initial length of the array has to be saved in a variable and this variable should be used in condition, because with each loop the length of array changes:
             var arrayLen:int = yourArray.length;
              for (var i:int = 0; i < arrayLen ; i++)
                   yourArray.pop();

  • How do u remove something from an array (char)

    (sorry im have just started to learn java.)
    if (Character.isWhitespace(inputTextArray[inputTextArray.length - 1]))
    inputTextArray[inputTextArray.length - 1] = null;
    how can i remove the value out of the position of the array im in.

    Once you've created an array, its size is fixed forever, so you cannot remove elements from it.
    What you will need to do is to construct a new array that contains the same text, but with the white space ommitted. Since you won't know how big the new array is until you've gone through the first one, you need something whose size is not fixed at the beginning.
    Given that you're dealing with text, I'd suggest you take a look at StringBuffer.
    Sylvia.

  • How do I use an array variable in the assignment target?

    Hi,
    I am creating a BPEL process in which I have to use an array variable. The array variable needs to be initialized based on some condition.
    The issue is I cannot find a way to set the value of the array variable. There are ways to GET the value of an array variable indexing into it.
    But how do I set the value by using the Array variable in the <to> tag?
    Any help is appreciated. I am using BPEL 10.1.2.0.2.
    Thanks.

    You can declare a variable of type integer which will server as your index. Figure out based on some condition in your process which index of array to update. Assign to your integer variable you created.
    And have Assign copy operation like this -
    <copy>
    <from variable="Var_Output_FetchDueDate"
    part="OutputParameters"
    query="/ns18:OutputParameters/ns18:DUEDATE"/>
    <to variable="outputVariable" part="payload"
    query="/client:GetCustomerAccountInformationProcessResponse/client:customer/client:accounts/client:account[$Var_Counter]/client:dueDate"/>
    </copy>
    I have been using this in my processes.

  • How to ask for an array and how to save the values

    I'm supposed to be learning the differences between a linear search and a binary search, and the assignment is to have a user input an array and search through the array for a given number using both searches. My problem is that I know how to ask them how long they want their array to be, but I don't know how to call the getArray() method to actually ask for the contents of the array.
    My code is as follows:
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Main
        private static Scanner input = new Scanner(System.in);
        public static void main (String args[])
            //creates ArrayList
            int List[];
            System.out.println("How long would you like the array to be?");
            int arrayLength = input.nextInt();
            //Initializes array list
            List = new int [arrayLength];
            System.out.println("Please enter the first value of the array");
        public static void getArray(int List[], int arrayLength)
            for(int i=0; i < arrayLength; i++) {
                 System.out.println("Enter the next value for array");
                 List[i] = input.nextInt();
         public static void printArray(int List[])
             for(int i=0; i < List.length; i++)
                 System.out.print(List[i] + " ");
    public class search
        public static int binarySearch(int anArray[], int first, int last, int value)
            int index;
            if(first > last) {
                index = -1;
            else {
                int mid = (first + last)/2;
                if(value == anArray[mid]) {
                    index = mid; //value found at anArray[mid]
                else if(value < anArray[mid]) {
                    //point X
                    index = binarySearch(anArray, first, mid-1, value);
                else {
                    //point Y
                    index = binarySearch(anArray, mid+1, last, value);
                } //end if
            } //end if
            return index;
        //Iterative linear search
        public int linearSearch(int a[], int valueToFind)
            //valueToFind is the number that will be found
            //The function returns the position of the value if found
            //The function returns -1 if valueToFind was not found
            for (int i=0; i<a.length; i++) {
                if (valueToFind == a) {
    return i;
    return -1;

    I made the changes. Two more questions.
    1.) Just for curiosity, how would I have referenced those methods (called them)?
    2.) How do I call the searches?
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Main
        private static Scanner input = new Scanner(System.in);
        public static void main (String args[])
            //creates ArrayList
            int List[];
            System.out.println("How many values would you like the array to have?");
            int arrayLength = input.nextInt();
            //Initializes array list
            List = new int [arrayLength];
            //Collects the array information
            for(int i=0; i < arrayLength; i++) {
                 System.out.println("Enter a value for array");
                 List[i] = input.nextInt(); 
            //Prints the array
            System.out.print("Array: ");
            for(int i=0; i < List.length; i++)
                 System.out.print(List[i] + " ");
            //Asks for the value to be searched for
            System.out.println("What value would you like to search for?");
            int temp = input.nextInt();
            System.out.println(search.binarySearch()); //not working
    }

  • How do you create an array without using a shell on the FP?

    I want to be able to read the status of front panel controls (value, control box selection, etc.) and save it to a file, as a "configuration" file -- then be able to load it and have all the controls set to the same states as were saved in the file. I was thinking an array would be a way to do this, as I have done that in VB. (Saving it as a text file, then reading lines back into the array when the file is read and point the control(s) values/states to the corresponding array element.
    So how do I create an array of X dimensions without using a shell on the front panel? Or can someone suggest a better way to accomplish what I am after? (Datalogging doesn't allow for saving the status by a filename, so I
    do not want to go that route.)

    Thanks so much m3nth! This definitely looks like what I was wanting... just not really knowing how to get there.
    I'm not sure I follow all the icons. Is that an array (top left with 0 constant) in the top example? And if so, that gets back to part of my original question of how to create an array without using a shell on the FP. Do I follow your diagram correctly?
    If I seem a tad green... well I am.
    I hope you understand the LabVIEW environment and icons are still very new to me.
    Also, I had a response from an NI app. engineer about this problem. He sent me a couple of VI's that he threw together approaching this by using Keys. (I still think you are pointing to the best solution.) I assume he wouldn't mind m
    e posting his reply and the VI's for the sake of a good, thorough, Roundtable discussion. So here are his comments with VI's attached:
    "I was implementing this exact functionality this morning for an application I'm working on. I only have five controls I want to save, but they are all of different data types. I simply wrote a key for each control, and read back that key on initialization. I simply passed in property node values to the save VI at the end, and passed the values out to property nodes at
    the beginning. I've attached my initialize and save VI's for you to view. If you have so many controls that this would not be feasible, you may want to look into clustering the controls and saving the cluster as a datalog file.
    Attachments:
    Initialize_Settings.vi ‏55 KB
    Save_Settings.vi ‏52 KB

  • How do I pass an array of structs to a C function using the dll flexible prototype adapter?

    What I want to do is pass into a C dll function a variably sized Array of structs of type TPS_Data. My Code compiles but when I run it in TestStand, I get an error -17001; Program Error. "Cannot allocate 0 size buffer Error in parameter 2, 'OpenFrdData'."
    I've allocated the Array of structs, and all of the information is there before I call my function, so is it my prototype? Or am I asking too much of the DLL Flexible Prototype Adapter to pass an Array of Structs?
    I can pass in a single struct of type TPS_Data and that works, but not an array.
    Here's the relevent code:
    typedef struct TPS_DATA
    char Report_Number[256];
    char System_Name[256];
    char Open_Date[256];
    char UUT_Part_Number[256];
    char UUT_Serial_Number[256];
    char UUT_Name[256];
    char Open_Employee_Name[256];
    char Open_Employee_Number[256];
    char Close_Employee_Name[256];
    char Close_Employee_Number[256];
    char Close_Date[256];
    } TPS_Data;
    typedef struct TPS_DATA_ARRAY
    TPS_Data DataRecord;
    } TPS_DataArray;
    long __declspec(dllexport) __stdcall OpenDialog (CAObjHandle Context, TPS_DataArray *TpsData[], const char *psFaultStr, char *sComments, const int nCount);

    OK,
    I can pass the data to the DLL function, using the following types:
    typedef struct StringArrayType
    char string[10][256];
    } StringArray;
    typedef struct MultiStringArrayType
    StringArray Record[10];
    } MultiStringArray;
    void __declspec(dllexport) __stdcall ATP_TestStructPassing(StringArray Strings)
    return;
    void __declspec(dllexport) __stdcall ATP_TestMultiStructPassing(MultiStringArray *Strings)
    return;
    But when the MultiStruct function Exits, TestStand reports an Error:
    -17501 "Unexpected Operating System Error" Source: 'TSAPI'
    There doesn't seem to be a way around this, and once the error occurs, I have to force quit TestStand. I've included the sequence file, and the dll code can be compiled from the fun
    ctions shown above.
    Any thoughts on how to get around this error would be greatly appreciated.
    Attachments:
    StructArrayPassing.seq ‏16 KB

Maybe you are looking for

  • How to create a chart with dates?

    I've created a table with projects I have to deliver and the date they were delivered. I would like to create a chart from this data - however I can't figure out how to use date in the chart. Ideally the chart would work with the date (lets say from

  • Why are my raw files from my Canon 5D Mark III dim in Lightroom 4.3?

    I am brand new to Lightroom, still reviewing various basic instruction videos, however I am adept in Photoshop CS5 and CS6. I have been able to import and move a file of jpegs but as I shoot jpeg/raw combo, the raw files were left behind in the origi

  • K1: apps are forced close + can't connect to internet + can't factory reset

    All of a sudden, my ideapad K1 keep poping up messages saying that **** has stopped unexpectedly and force close.  I try to upgrade the fireware while realize there is no wifi connect (the wifi works well on my other devices). After trying tons of me

  • IPod synced with a Mac won't sync with Windows

    I got my touch on christmas and synced it to my brother's Mac. He left back to college and now that I'm back home i want to sync it to my Windows computer so i can have my music on it. Ive tried plugging it into two Windows computers and it isn't bei

  • How to get the real client ip from HttpClusterServlet?

    Hi All,           WL 6.0 sp2 on Linux.           When HttpClusterServlet is used, invoking HttpServletRequest.getServerName()           will return the server name of the proxy server where HttpClusterServlet           installed,           rather tha