Tuesday, April 4, 2017

Remove duplicate entries from ArrayList or List without using collection

Remove duplicate entries from ArrayList or List without using collection.


package testMavProject;

import java.util.ArrayList;

public class removeDuplicate {

public static void main(String[] args) {
// Create a ArrayList type of Integer or other datatype.
ArrayList<Integer> aList=new ArrayList<Integer>();
aList.add(5);
aList.add(7);
aList.add(5);
aList.add(6);
for(int i=0;i<aList.size();i++){
for(int j=i+1;j<aList.size();j++)
{
//Check for duplicate value using if condition
//If you are comparing Integer then you could use "==" sign; if you have string values then user equals method instead of ==. 
if(aList.get(i)==(aList.get(j)))
{
//if values matched then remove the value from J index and back your J index to previous index J--
aList.remove(aList.get(j));
j--;
}
}
}
//Print your list without duplicate value.
System.out.println(aList);
}

}

How to optimize SQL query?

How to optimize SQL query?

  • Use Indexes Properly.
  • Only retrieve the data you really need.(prefer using where clause)
  • Avoid the use of functions in where clause.
  • Avoid using SQL subqueries or nested queries. Use JOINS instead.
  • Avoid Wildcard characters at the beginning of the LIKE statement.





Saturday, March 18, 2017

Maloom na tha itna kuchh hai bechne ko ghar me

معلوم نہ تھا اتنا کچھ ہے بچنے کو گھر مے 
زمیں سے لیکر ضمیر تک سب بک رہا ہے

Maloom na tha itna kuchh hai bechne ko ghar me
Zamin se lekar Zameer tak sab bik raha hai

 Mirza Ghalib



Sunday, March 12, 2017

A tree 🌲 without leaf 🍃 🍂 #tree #leaf #branches #withoutrain #dry #jorvee

A tree 🌲 without leaf 🍃 🍂

Autumn session is going on, trees are dropping their leaves and becoming undressed and nacked, but intresting this is also like a new birth for trees, where trees will get new leaves as their new dress. :) 

A tree without leaf


 #tree #leaf #branches #withoutrain #dry #jorvee via Instagram

Sunday, March 5, 2017

Don't be Shock, when these politicians win in upcoming poll. Hindustan Times, 5th March 2017 #warofpolitics #politics #politicians #battlefield #Jorvee

Don't be Shock, when these politicians win in upcoming poll.

the world is becoming against the muslims and Islam. In every satate in world have a political party who are gainst the Islam and hate the people on the name of their religion. 
And the intresing thing is that they are winning the match in arena of politics. So in 2017 so many countires are ready for poll, let see what will be the result and outcome, whom society will elect.

We have some politician like that in Netherlands, Germany, France and Bulgaria.

 Hindustan Times, 5th March 2017

 #warofpolitics #politics #politicians #battlefield #Jorvee via Instagram

Popular Posts