Help: I'm stuck doing a java program with functions & lists


#1

This is my program,

import java.util.*;

public class Newfcal
{
	public static void main (String args[])
	{

		Scanner a1=new Scanner(System.in);
		System.out.println("Enter your name");
		String fn1=a1.nextLine();									//Getting the name of the user//	

		System.out.println("Enter your friend's name");
		String fn2=a1.nextLine();									//Getting the name of the friend//

		Assign b1 = new Assign();
    		List<String> names = b1.names();								//Assigning the return of names list into a list//

		Calculate c1 = new Calculate();
    		List<String> counter = cb1.counter();								//Assigning the return of names list into a list//

		System.out.println(counter);						
	}


	public static String Assign(String fn1, String fn2)							//Function to assign names into arrays//
	{
		ArrayList<String>names = new ArrayList<String>(fn1, "and", fn2);				//Defining the list to store the names//
    
		names = names.replaceAll("\\s+","");								//Removing the white spaces in the list//
									
		return(names);											//Returning the names list//
	}

		
	public static int[] Calculate(String names)								//Function to do the calculations//
	{
		int count=1;											//Variable to store the count of each letter//
		List counter = new ArrayList();									//Defining the list//

		for(int element=0; element<=names.length; element++)						//Loop to go through the elements one by one//
		{
			for(int run=1; run<=names.length; run++)						//Loop to check for similar letters//
			{
				if(names[element]==names[run])							//Condition to check if the elements are equal//
				{
					count++;								//Increase the conter//
					names.remove(run);							//Remove the similar elements//					
				}
			}
			
			names.remove(element);									//Remove the element used to compare//
			counter[element]=count;									//Assigning the count to a list//
		}

		return(counter);		
	}

}

I can't find out what is wrong with the program. I used a lot of internet resources to develop this code. Please help me with the errors in this code,