Computer Science, asked by priyamchatterjpdxuo4, 11 months ago

Write a program in Java to accept a name as first name with surname insert a middle name as Kumar and display the full name

Answers

Answered by mmainak968
0

I have a form with a full-name EditText 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?

If user enter his/her name like A B C . First name will be A & Last Name Will BC

I am trying This :

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();

   }

}

Similar questions