Hi there I am new to java, studying in my bs course from a couple of weeks. So please don't mind if I ask something stupid. btw coming to the point. Assignment was that you have to write a program in which I have to break the email address into parts using StringBuffer e.g: if the given email is hassanaqve@gmail.com so I have to break it like username: hassanaqve domain name : gmail extension : .com
I tried myself but it is not working there are no errors but also not giving output
import java.lang.*;
public class Lab5 {
public static void main(String[] args) {
StringBuffer email = new StringBuffer ("Hassanaqve@gmail.com");
for ( int i=0; i<= email.length(); i++){
if ( email.substring (i).equals ("@")){
System.out.println( "Username : " + email.substring(0,i));
int j=i;
for ( int p=0; j<= email.length(); p++ ){
if ( email.substring (p) == (".")){
System.out.println( "doamin : " + email.substring(j,p));
System.out.println( "extention : " + email.substring(p+1,p+4));
}
}
}
}
}