NavigatableSetExample:Error with the code

import java.util.*;

import java.util.concurrent.*;

publicclass NavigableSetExample{

publicstaticvoid main(String[] args){

System.out.println("Navigable set Example!\n");

NavigableSet <Integer>nSet =new ConcurrentSkipListSet<Integer>();

nSet.add(10);

nSet.add(20);

nSet.add(50);

nSet.add(30);

nSet.add(100);

nSet.add(80);

// Returns an iterator over the elements in navigable set, in ascending order.

Iterator iterator = nSet.iterator();

System.out.print("Ascending order navigable set: ");

//Ascending order list

while (iterator.hasNext()){

System.out.print(iterator.next() +" ");

}

System.out.println();

//Descending order list

System.out.println("Descending order navigable set: " + nSet.descendingSet() +"\n");

//Greater than or equal to the given element

System.out.println("Least element in Navigable set greater than or equal to 35: " + nSet.ceiling(35));

//Less than or equal to the given element

System.out.println("Greatest element in Navigable set less than or equal to 35: " + nSet.floor(35) +"\n");

//Viewing the portion of navigable set whose elements are strictly less than the given element

System.out.println("Navigable set whose elements are strictly less than '40': " + nSet.headSet(40));

//Viewing the portion of navigable set whose elements are greater than or equal to the given element

System.out.println("Navigable set whose elements are greater than or equal to '40': " + nSet.tailSet(40) +"\n");

//Removing first element from navigable set

System.out.println("Remove element: "+nSet.pollFirst());

//After removing the first element, now get navigable set

System.out.println("Now navigable set: " + nSet.descendingSet() +"\n");

//Removing last element from navigable set

System.out.println("Remove element: " + nSet.pollLast());

//After removing the last element, now get navigable set

System.out.println("Now navigable set: " + nSet.descendingSet());

}

}

Error:

NavigableMap cannot be resolved to a typeNavigableMapExample.javaline 7

this isthe error i am getting.

[3462 byte] By [swetha123@sa.coma] at [2007-11-27 11:32:13]
# 1

Are you sure this is the class that gives you the error?

I see no NavigableMap* here -- just NavigableSet*.

Please post the whole error.

java_knighta at 2007-7-29 16:44:15 > top of Java-index,Core,Core APIs...
# 2

import java.util.*;

import java.util.concurrent.*;

public class NavigableSetExample{

public static void main(String[] args) {

System.out.println("Navigable set Example!\n");

NavigableSet <Integer>nSet = new ConcurrentSkipListSet<Integer>();

nSet.add(10);

nSet.add(20);

nSet.add(50);

nSet.add(30);

nSet.add(100);

nSet.add(80);

// Returns an iterator over the elements in navigable set, in ascending order.

Iterator iterator = nSet.iterator();

System.out.print("Ascending order navigable set: ");

//Ascending order list

while (iterator.hasNext()){

System.out.print(iterator.next() + " ");

}

System.out.println();

//Descending order list

System.out.println("Descending order navigable set: " + nSet.descendingSet() + "\n");

//Greater than or equal to the given element

System.out.println("Least element in Navigable set greater than or equal to 35: " + nSet.ceiling(35));

//Less than or equal to the given element

System.out.println("Greatest element in Navigable set less than or equal to 35: " + nSet.floor(35) + "\n");

//Viewing the portion of navigable set whose elements are strictly less than the given element

System.out.println("Navigable set whose elements are strictly less than '40': " + nSet.headSet(40));

//Viewing the portion of navigable set whose elements are greater than or equal to the given element

System.out.println("Navigable set whose elements are greater than or equal to '40': " + nSet.tailSet(40) + "\n");

//Removing first element from navigable set

System.out.println("Remove element: "+nSet.pollFirst());

//After removing the first element, now get navigable set

System.out.println("Now navigable set: " + nSet.descendingSet() + "\n");

//Removing last element from navigable set

System.out.println("Remove element: " + nSet.pollLast());

//After removing the last element, now get navigable set

System.out.println("Now navigable set: " + nSet.descendingSet());

}

}

these are the errors i am getting.

swetha123@sa.coma at 2007-7-29 16:44:15 > top of Java-index,Core,Core APIs...
# 3

NavigableSetExample.java:7: cannot find symbol

symbol : class NavigableSet

location: class NavigableSetExample

NavigableSet <Integer>nSet = new ConcurrentSkipListSet<Integer>(

);

^

NavigableSetExample.java:7: cannot find symbol

symbol : class ConcurrentSkipListSet

location: class NavigableSetExample

NavigableSet <Integer>nSet = new ConcurrentSkipListSet<Integer>(

);

^

2 errors

swetha123@sa.coma at 2007-7-29 16:44:15 > top of Java-index,Core,Core APIs...
# 4

Hi

I can run your program pretty well. I guess your jre is not 1.6 compliant.

You need to install java 1.6 and if you are using tools like eclipse you should also configure it to use java 1.6.

AshwineeJhaa at 2007-7-29 16:44:15 > top of Java-index,Core,Core APIs...