Computer Science Java

posted by .

Alright I have these strings

String domain1 = ". com";
String domain2 = ". edu";
String domain3 = ". org";

I want to make sure that when the user puts in their username (their email) that the domain will be the last four characters. How do I get this to happen? Thank you

  • Computer Science Java -

    if (s.matches("\\.(com|edu|org)$")) {...} else {...}

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. computer science /use java language

    write the program that inputs a string representing a binary number(0s and 1s). First, your program should veerify that it is indeed a binary number, that is, the number contains only 0s and 1s . if that is not the case, your program …
  2. programming

    write a program that maintains two parallel arrays. after th arrays have been loaded the program should behave as a login screen prompting for username and password. the program should respond three output messages. if username does …
  3. Computer Science-Java

    Hi, I have to write a method that returns my first name, middle initial, and last name as a single String and call the method in java. So far, I have: public class ReturnName { static String fullname(String firstname, String middleinitial, …
  4. physics

    A picture hangs on the wall suspended by two strings, with è = 61°. The tension in string 1 is 1.8 N. è is connected to string 1, and 32° is connected to string 2. (a) Is the tension in string 1 greater than, less than, or equal …
  5. physics

    A ball(mass=3kg) is attached to 2 strings and it is rotated by one string and to the other is joined to another ball which is also attached to another ball by a string.Which of the strings experience the maximum when length of each …
  6. Java

    Write a method that will take in a String parameter and return true if the first 2 chars in the string also appear at the end of the string, such as with the word "edited", which starts and ends with 'e' and 'd'.
  7. java.please help

    Write a Java program that prompts the user for a string. If the string entered by the user does not start with Hello and does not end with a digit, print incorrect and re-prompt the user. Otherwise, print Thank you.
  8. Computer Science

    For this task you will create a program that prints out a user-specified string. Then, on the next line, it prints out the string again, all except the last character. It continues printing the string with one less character on each …
  9. maths

    String p is 3 times as long as string q. string r is 3m longer than half the total length of strings p and q. If the total length of all three strings is 54oocm what is the length of string r.
  10. physics

    A picture hangs on the wall suspended by two strings, as shown in the figure, with θ = 65°. The tension in string 1 is 1.3 N. (a)Is the tension in string 2 greater than, less than, or equal to the tension in string 1?

More Similar Questions