Write a java program to find username from a valid email string.

Write a program to read a valid email id and extract the username.

Note – username is the string appearing before @ symbol.

Input and Output Format:
Input consists of a string.
The output consists of string.
Refer sample output for formatting specifications.

Sample Input 1:

Sample Output 1:

Find username from a valid email string in java.

import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s1 = sc.nextLine();

  public static void getvalues(String s1) {

    StringTokenizer st = new StringTokenizer(s1, "@");
    String s2 = st.nextToken();


Add a Comment

Your email address will not be published. Required fields are marked *

20 − eleven =