i have an assignment my lecturers give to me, but i really dont have any idea about this

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CountSymbols {

 * @param args
 static void printsymbols(String inp,String sym){
     int count=0;
     Pattern p=Pattern.compile(sym);
     Matcher m=p.matcher(inp);
     System.out.println(sym+" has "+ count+" times");
public static void main(String[] args) {
    // TODO Auto-generated method stub

    Scanner in=new Scanner(System.in);
    System.out.println("Enter the Symbol");
    String sym=in.nextLine();
    System.out.println("Enter the String");
    String inp=in.nextLine();



Enter the Symbol


Enter the String

i@ the @ inp@ str@ing

@ has 4 times

Leave a Comment