Hey! I'm taking my first CS class and new to all this...

i'm using eclipse. i need to prompt the user to enter their FULL name ie. John Smith. i cannot ask the user to enter their 1st and last name separately.
i then have to print/display the name in the lastName, fullName format ie. Smith, John.

i'm able to prompt the firstname lastname and display it, but i cannot seem to separate them. i need this so i can then get the # of characters of firstname, last name and fullname... but that i know how to do.

thanks!!

String fullName;
String firstName;
String lastName;

fullName = JOptionPane.showInputDialog("Please enter your name" );
System.out.println("");

Recommended Answers

All 2 Replies

Look at the String class's split method for one way to separate a String into parts.

StringTokenizer could come in handy, as well

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.