How do you find the last name?
Topic: Case select in java
July 16, 2019 / By Doretta Question:
Erik V. Agard
Fang Y. Cao
Tyler L. Fultz
Mary Ann Dvorsky
Robert P. Huang
Cy A. Neita
Pope Benedict XVI
Nancy Y. Wen
Jonathan B. Song
Ari W. Schaler
Martin Luther King, Jr.
Michael J. Lee
Grace S. Hummel
Brian R. Goodall
Daniel A. Farias
King Henry VIII
Miranda L. Bernard
James D. Hill
Daniel S. Naval
T. J. Elliott
Rafael G. Setra
Jed T. Tan
These are the names of the people. Now, I have to write a method in Java to find the last name. PLEASE HELP ME!
Best Answers: How do you find the last name?
Cassidy | 2 days ago
==>Store the names in an array.
==>There are multiple possibilities
•If the given name consists of two parts, that is, the first name and the last name, then you can use the string.indexOf(" ") method to determine the location of space and consider the name occurring after the space as the second name
• If the name consists of three parts, that is the first name, middle name and the last name, you can use string.lastindexOf(" ") to determine, the last occurrence of space, and consider the name occurring after that position as the last name.
•If the first name is followed by an initial, followed by a period and then the last name, use the indexOf(".") method to find out its position and then obtain the last name, using the substring() method.
==> However, I'm not sure how to find out the last name in case of King Henry VIII. How do you find that? What is the last name?
Try coding as per this suggestion.
Hope this helps. If it does, please select my answer as the best one!! Happy programming :)
👍 212 | 👎 2
Did you like the answer? How do you find the last name?
Share with your friends
We found more questions related to the topic: Case select in java
You will have to capture the last part of each name, which will give you the last name. But if the last name is preceded with a comma or if the last name is a roman number, you will have to go to the part before that. You could use a tokenizer or a regex.
👍 90 | 👎 -7
If the names are in an array, then go through the array and do a string compare for the name you're looking for. Say its held in variable searchName
searchName = "Naval";
if (searchName.compareTo("Naval")==0)//foun... it
do some thing
👍 89 | 👎 -16
Originally Answered: I have W XP Home ,I have cdRW &I don't find any software to use to burn.Where can I find.?
Infra recorder - If you don’t have a Nero (OEM or retail) for your CD or DVD burner or some other burner application, Infra recorder is a good free alternative. Not only that, it’s a lot less bloated and it has a small memory foot print. While Nero has some great functionality, it comes with too many applications and extra features that gunk up the system though you don’t have to install all those features. It won’t let you do simultaneous DVD or CD burning or other advanced things that Nero lets you do, but it does what it does well and it’s a lot better than what comes with Windows XP or Vista.