Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. public Contact[] getPhoneContacts() {
  2.        
  3.         if (contacts == null)
  4.             return null;
  5.        
  6.         int noOfPhoneContacts = 0;
  7.         int phoneContactsIdx = 0;
  8.        
  9.         for (int i = 0; i < contacts.length; i++)
  10.             if ((contacts[i].getType()).equals("Phone"))
  11.                 noOfPhoneContacts++;
  12.        
  13.         Contact[] phoneContacts = new Contact[noOfPhoneContacts];
  14.        
  15.         for (int i = 0; i < contacts.length; i++)
  16.             if ((contacts[i].getType()).equals("Phone"))
  17.                 phoneContacts[phoneContactsIdx++] = contacts[i];
  18.        
  19.         return phoneContacts;
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement