please Help me out, i'm new in java and i want code for following program.

write a program that takes a series of email addresses as a command-line argument and, after parsing/processing the input, display the addresses separately and in alphabetical order at the command window. For example if the email addresses are provided as a long concatenated string like the following:


And then the result shown on the command window should be something like:


In order to qualify as an email address acceptable to us, every entry must be conforming to the following criterion:

• The prefix or the user-id (i.e. the characters before @) should contain at least 6 and maximum of 15 characters.
• The domain name (i.e. the characters after @ and before dot) should contain at least 3 and maximum of 8 characters.
• The extension (i.e. the characters after dot) must contain exactly 3 characters.
• The extension must be one of the following three types: com, org and edu.

Any email address not conforming to the above criteria must be ignored and not displayed in the final output. For example if the input string is:


Then the result shown on the command window should only be:


6 Years
Discussion Span
Last Post by NormR1

Per our forum rules:
Do provide evidence of having done some work yourself if posting questions from assignments.

Please post your current code, specific questions, error messages, pseudocode, or anything to demonstrate that you are making some effort towards solving this yourself if you wish to receive further help with it.

import java.util.regex.Matcher;   
import java.util.regex.Pattern;   

public class EmailParser{   
public static void main(String args[]){       
      String emailAddress = args[0];
      String[] parts = emailAddress.split(".com" || ".org" || ".org");
	for(int i=0; i<parts.length; i++)
 private static boolean isValidEmail(String parts[i])
  Pattern pattern=Pattern.compile("[^@.]{6,15}@\\w{3,8}\\.(com|org|edu)$");
  Matcher matcher = pattern.matcher(parts[i]);   
  return matcher.matches();   
  }  }

The code works well for the constraint/limitations that are given in the program but does't get the the emails containing the command line argument into the separate line in alphabetical order


Are all the email addresses in the first element of the args array?
Your code doesn't test if the the args array to see if it's empty or has more than one element.
How do you detect the end of one domain and the beginning of the next name?
Answer: the extension is fixed at 3 letters

Edited by NormR1: n/a


Any email address not conforming to the above criteria must be ignored

How do you detect the end of one extension and the beginning of the next name if the extension is NOT 3 characters? What if the extension is orgXX?
Without a space after the extension, the XX would be moved to the name of the next address.


The code works well

private static boolean isValidEmail(String parts[i])

This does NOT compile???

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.