Thursday, October 11, 2012

How to compate objects value of two diffrent list in Java

Java Code for above issue...

 public static class A  {


        String  headerName;

        public String getHeaderName() {
            return headerName;
        }
        public void setListBoxHeaderName(String headerName) {
            this.headerName= headerName;
        }
        public A(String headerName) {
            super();

            this.headerName = headerName;
        }


        public boolean equals(A rData) {
            boolean bEqual = false;
            if (this.getHeaderName() != null && rData.getHeaderName() != null
                    && this.getHeaderName().equals(rData.getHeaderName())) {
                bEqual = true;
            }
            return bEqual;
        }

    }
And for comparing two list the code is as follows...
for (A value1 : listA1) {
            for (A value2: listA) {
                if (value2.equals(value1 )) {
                 listA.remove(value2);
                    break;
                }
            }
        }
This is what the exact solution i used Thanks

No comments:

Post a Comment