Hi experts,

I have a question on generating a hashtable which contains only unique numbers. Can anyone help me out. My code is here.
I want to check if the key and value are in the hashtable or not. if they are in the hashtable i break to start generate a random row and column and then check whether the pair is in the hashtable or not. I could not figure out how to do. Also i get an error when breaking to the label start. the compiler says undeclared START. Can anyone help me please. I need it urgent.

while(counter != random_Value){
         START:
            randomRow = random_element.nextInt(9);
            randomColumn = random_element.nextInt(9);
            if(!(mapRowCol.containsKey(randomRow)))
            {
                mapRowCol.put(randomRow, randomColumn);
                System.out.println("Row, Col: " +mapRowCol.entrySet());
            }
            else{
                System.out.println();
               // break START;
            }
            counter++;
            System.out.println("Counter: "+counter);
   }

Thank you very much. Little help is appreciated !

I don't really know how to elaborate on the compiler's error message. It literally says exactly what the problem is: you're using a variable "START" which was never declared, which is illegal. Either declare it or get rid of it. It looks useless to me; so delete it. And where you have break START; it should say "break;"

BREAK appears to be a valid label
http://java.sun.com/docs/books/jls/second_edition/html/statements.doc.html#78993
and the break with a label also seems valid
http://java.sun.com/docs/books/jls/second_edition/html/statements.doc.html#6842
I just ran them thru Eclipse (Java 1.6u20) and they generated no errors, although the label does seem completely redundant in this case.

What exactly was the error message and exactly which line did it refer to?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.