Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Error when trying to use ArrayComparator

  1. #1
    Member
    Join Date
    Mar 2011
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error when trying to use ArrayComparator

     
    import java.util.*;
    public class c02 {
     
        public static void main(String[] args) {
            String[][] catalogue = new String[99][4];
            boolean endProg, inputOK;
            String input, product, code, price, phrase;
            int count = 0;
     
            Scanner sc = new Scanner(System.in);
           // ArrayComparator ac=new ArrayComparator(0, "asc");
     
            do {
                endProg = true;
                System.out.print("Enter prodduct description (# to stop) : ");
                input = sc.nextLine();
                if (input.equalsIgnoreCase("#")) {
                    endProg = false;
                    break;
                }
                product = input;
                System.out.print("Enter prodduct code: ");
                input = sc.nextLine();
                code = input;
                System.out.print("Enter prodduct unit price: ");
                input = sc.nextLine();
                price = input;
                System.out.print("Enter prodduct unit phrase: ");
                input = sc.nextLine();
                phrase = input;
                catalogue[count][0] = code;
                catalogue[count][1] = product;
                catalogue[count][2] = price;
                catalogue[count][3] = phrase;
     
                count++;
     
            } while (endProg);
     
            Arrays.sort(catalogue, new ArrayComparator(0, "asc") {});
     
            System.out.println("Your Catalog: ");
    ...

    error for the following code:
    Compiling 2 source files to I:\TestCode\build\classes
    I:\TestCode\src\c02.java:44: error: cannot find symbol
            Arrays.sort(catalogue, new ArrayComparator(0, "asc") {});
      symbol:   class ArrayComparator
      location: class c02
    1 error
    I:\TestCode\nbproject\build-impl.xml:915: The following error occurred while executing this line:
    I:\TestCode\nbproject\build-impl.xml:268: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 1 second)


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,321
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: Error when trying to use ArrayComparator

    Where is the class ArrayComparator defined? The compiler can not find its definition.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Mar 2011
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error when trying to use ArrayComparator

    Quote Originally Posted by Norm View Post
    Where is the class ArrayComparator defined? The compiler can not find its definition.
    based on this java doc i thought ArrayComparator already being defined by java

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,321
    Thanks
    56
    Thanked 2,374 Times in 2,345 Posts

    Default Re: Error when trying to use ArrayComparator

    That link doesn't look like it is part of the Java SE API.
    See: Java Platform SE 7

    If you want to use some third party classes, you need to put their definitions on the classpath when you compile and when you execute the code that uses them.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Mar 2011
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error when trying to use ArrayComparator

    sorry abt the mistake... i got my code to work already... thanks for the help

Similar Threads

  1. Please! Help me to this error "ERROR CANNOT FIND SYMBOL"
    By mharck in forum Object Oriented Programming
    Replies: 8
    Last Post: July 3rd, 2012, 10:20 AM