Question
Given a String variable email, write code using split method to print email id and domain in separate lines. Example: email -> info@yahoo.com Print: Email
Given a String variable email, write code using split method to print email id and domain in separate lines.
Example:
email -> info@yahoo.com
Print:
Email id: info
Email domain: yahoo.com
If email contains no @ character or multiple @ characters then print invalid email:
email -> hello-yahoo.com
print:
invalid email
email -> my@fancy@email.com
print:
invalid email
----------------------------------------
import java.util.*;
class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); String email = input.nextLine(); //Write your code below } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started