title: java : Make it the best "Searching method"
body: <p>I have design the search method. According to my requirement, If a user wants to search a customer’s record, he/she can input the customer’s family name or given name into the name text field and then click the search button. The following two screen shots show  an example of  the events before and after button click (with input the name to be searched is Lee)</p>
  
  <p><img src="https://i.stack.imgur.com/DFZod.jpg" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/Xlnf7.jpg" alt="enter image description here"></p>
  
  <p>And below is the code for searching. It is working fine but I want to make it better?</p>
  
  <pre><code> private void search()
          {
              String studentName=CNameTextField.getText();
              String record="";
              int count=0;
  
              for(int i=0; i&lt;myList.size();i++)
                {
                  String name=myList.get(i).getName();
  
                   String [] splitName= name.split(" ");
  
                   if(studentName.equals(splitName[0]) || studentName.equals(splitName[1]))
                      {
                          count++;
                          record=record+"\n"+myList.get(i).toString();
  
                      }
                  display.setText("");
                  display.append(count + " result(s) found for "+ studentName);
                  display.append("\n "+ record);
                }
  
  
      }
  </code></pre>