how to create a custom datatype in java?
<p>I want to create an custom datatype in Java,for example datatype Email , that having following method isValidate(String email),isEmailExist(String email),getDomain(String email), get Id(String email),just like Integer class in java.</p>

<p>Integer is a class and I can initialise the object of Integer class as follows:</p>

<p>Integer i = 100;</p>

<p>I created my class Email and I want to initialise it as follows 
Email e = "sam";</p>

<p>How can i perform this functionality in my Email class.<pre>import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;</p>

<p>public class Email
{
   private String email;
    public Email(String email)
    {
        this.email=email;
    }</p>

<pre><code>Email() {

}

public Boolean isvalid(String email)
{
</code></pre>

<p>String lastToken = null;
  Pattern p = Pattern.compile(".+@.+\.[a-z]+");
   // Match the given string with the pattern
   Matcher m = p.matcher(email);
   // check whether match is found
   boolean matchFound = m.matches();
   StringTokenizer st = new StringTokenizer(email, ".");
   while (st.hasMoreTokens())
   {
      lastToken = st.nextToken();
   }</p>

<p>if (matchFound &amp;&amp; lastToken.length() >= 2
      &amp;&amp; email.length() - 1 != lastToken.length())
   {</p>

<pre><code>  return true;
</code></pre>

<p>}
   else
       return false;</p>

<pre><code>}
</code></pre>

<p>public String toString() {
    return email;
    }</p>

<p>}</p>

<p></pre></p>

<p>Thanks</p>
