illegal start of type ???

Hello,
I have that code which compares three data structures [array - array2, binaryTree - binarytree2, hashtable - hashtable2]
but it returns an error "illegal start of type"

Can anyone declare what's going wrong ???
Thanks in advance !

public class Compare
{
   
    String returnString = new String("");
   
    for (int i = 0; i< array2.length; i++)
    {
        boolean containedinone = false;
        for (int j = 0; j < array1.length; j++)
        {
            if (array1[j].equals(array2[i]))
            {
                containedinone = true;
            }
        }
        if (!containedinone)
        {
            returnString = returnString + "," + array2[i];
        }
    }
    if (returnString.equals(""))
    {
        return "SAME";
    }
    else
    {
        return returnString;
    }
   
    boolean compare(BinaryTree a, Tree2 b) {
    Iterator ita = a.iterator();
    Iterator itb = b.iterator();
    boolean result = (a.size() == b.size());
    while(ita.hasNext() && itb.hasNext() && result) {
         if(!ita.next().equals(itb.next())) {
            result = false;
           }
        }
      return result;
   }
   
     if (!Hashtable2.containsValue(Hashtable.get(key))) {
                System.out.println("Map one has value \"" + mapOne.get(key) +
                        "\" and mapTwo does not.");
                    }
                }
                 
perdoname_Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cmalakarCommented:
Your code has many basic problems...

You cannot write code directly inside the class...

It should be inside any of the function or constructor or static block..

 for (int i = 0; i< array2.length; i++) //Code starting with this for loop should be inside a function..
This is what is causing the error "illegal start of type"
   
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
krakatoaCommented:
You alreaady asked the same question previously in which the same answers were mentioned.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.