Want a method that returns number of occurences of given number as argument of that method


#1

import java.util.Scanner;
class FirstOccur{
	public static void main(String[] s){
	Scanner sc=new Scanner(System.in);
	int length= sc.nextInt();
	int[] arr=new int[length];
		System.out.println("Enter Arayy list:");
		for(int i=0;i<length;i++){
			arr[i]=sc.nextInt();
		}
		int count=0;
		int m1(int x){
			int y=x;
			for(int j=0;j<length;j++){
			if(arr[j]==y){
				count++;
			}
			}
			return count;	
		
		}
			System.out.println(f);
	}
}

/*

 FirstOccur.java:12: error: ';' expected
                int m1(int x){
                      ^
FirstOccur.java:12: error: ';' expected
                int m1(int x){
                            ^

what is the error i don't understand please take a look...coders :slight_smile:


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.