/**
* SubStringDemo.java separates domain name like "@yahoo.com"
* from email id like "[email protected]"
*
*/
publicclass SubStringDemo {
/**
* @author suraj.gupta
*/
publicstaticvoid main(String[] args) {
String s = "[email protected]"; // email id in a String
int IndexOf = s.indexOf("@"); // returns an integer which tells the position of this substring "@" in the parent String "[email protected]"
String domainName = s.substring(IndexOf); //prints the String after that index
System.out.println("Taking Domain name from an email id "+domainName);
}
}