?
Solved

illegal start of type ???

Posted on 2008-02-06
2
Medium Priority
?
726 Views
Last Modified: 2008-02-07
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.");
                    }
                }
                 
0
Comment
Question by:perdoname_
2 Comments
 
LVL 23

Accepted Solution

by:
cmalakar earned 1000 total points
ID: 20838095
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
 
LVL 17

Expert Comment

by:krakatoa
ID: 20839520
You alreaady asked the same question previously in which the same answers were mentioned.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month5 days, 22 hours left to enroll

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question