title: How To Split First & Last Name String From Full Name In Android
body: <p>I have a form with a full-name <code>EditText</code> field and I would like to break the string into a first and last name strings .  Can any one help me on this? May I know what is the correct way to achieve my objective?</p>
  
  <p>If user enter his/her name like <code>A B C</code> . First name will be <code>A</code> &amp; Last Name Will <code>BC</code></p>
  
  <p>I am trying This :</p>
  
  <pre><code>EditText UNSP =(EditText)findViewById(R.id.UserNameToSIGNUP);
      String UserFullName=UNSP.getText().toString();
  
      String[] arr=UserFullName.split(" ");
  
      String fname=arr[0];
      String lname=arr[1];
  
      Log.d("First name",fname);
      Log.d("last name",lname);
  
  
  
      if(UserFullName.length()==0) {
  
          Toast.makeText(getApplicationContext(), "Submit Name", Toast.LENGTH_SHORT).show();
      }
  
      else{
  
           Toast.makeText(getApplicationContext(), "Success", Toast.LENGTH_SHORT).show();
  
  
      }
  
  }
  </code></pre>