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 10 of 10

Thread: CompareToIngnore case problem

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default CompareToIngnore case problem

    Okay so here are the two methods I'm having issues with. I need to sort two arrays ingoring case. I thought it would be as simple as chaning the compareTo -->compareToIgnoreCase. But when I do this the compiler tells me

     
    SortSearchUtil.java:63: cannot find symbol
    symbol : method compareToIgnoreCase(java.lang.Comparable)
    location: interface java.lang.Comparable

    if(array[searcher].compareToIgnoreCase(array[rs])<0)



    Please help
    public static int binarySearch(Comparable[]array, Comparable target)
    	{
    	int min, mid, max;
    	min = 0;
    	max = array.length-1;
    	int found = -1;
    	do
    	{
    		mid =(max+min)/2;
    		if(array[mid].compareTo(target)<0)
    			min=mid+1;
    		else if(array[mid].compareTo(target)>0)
    			max=mid-1;
    		else
    			{found = 1;
    			return mid;}
    	}while(found == (-1) && min <= max);	
    	return found;
    	}	
     
     
    public static void sortAddresses(Comparable [] array)// class create will own compareto method. geraric
    		{
    			int ms, rs, searcher;		
    			Comparable temp;	
    			for(ms = 0; ms<array.length-1; ms++)
    				{
    					rs = ms;
    					for(searcher = ms+1; searcher<array.length;searcher++)
    					{	
    						if(array[searcher].compareToIgnoreCase(array[rs])<0)//based on the type of the object making the call.
    						rs = searcher;
    					}
    					temp = array[ms];
    					array[ms] = array[rs];
    					array[rs] = temp;				
    				}
    			}//end method


  2. #2
    Member DavidFongs's Avatar
    Join Date
    Oct 2010
    Location
    Minneapolis, MN
    Posts
    107
    Thanks
    1
    Thanked 45 Times in 41 Posts

    Default Re: CompareToIngnore case problem

    Here is the comparable interface javadoc: Comparable (Java Platform SE 6)

    Does the method you are trying to use actually exist?

  3. The Following User Says Thank You to DavidFongs For This Useful Post:

    newTaz (November 7th, 2010)

  4. #3
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    489
    Thanks
    8
    Thanked 45 Times in 43 Posts

    Default Re: CompareToIngnore case problem


  5. #4
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: CompareToIngnore case problem

    Quote Originally Posted by Darryl.Burke View Post
    Sorry for the cross post... I am new to using these sites.

  6. #5
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    489
    Thanks
    8
    Thanked 45 Times in 43 Posts

    Default Re: CompareToIngnore case problem

    On the other forum, I have reported this cross poster for its abusive response which is a clear violation of the terms of use of that site.

    db

    edit Another abusive response on the other thread, also reported.

  7. #6
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: CompareToIngnore case problem

    Quote Originally Posted by Darryl.Burke View Post
    On the other forum, I have reported this cross poster for its abusive response which is a clear violation of the terms of use of that site.

    db

    edit Another abusive response on the other thread, also reported.
    Dude you really need to get a life... and yes i did try to call you a **** because you are kind of acting like one...
    Last edited by copeg; November 7th, 2010 at 04:23 PM.

  8. #7
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    489
    Thanks
    8
    Thanked 45 Times in 43 Posts

    Default Re: CompareToIngnore case problem

    Abuse reported. Violations of the terms of use are not tolerated on any forum.

    db

  9. #8
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: CompareToIngnore case problem

    Ok, I hate to say it but, Darryl.Burke Darryl.Burke, you're starting to overdue it.

    Sometimes it can take a while to get an answer. I've been there. People sometimes need help and may care more about getting a bad grade due to long response time than they do about the rules of some fourm, not this forum by the way.

  10. #9
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: CompareToIngnore case problem

    [error] what does this do?
    [/error]

    Ok, how did you get that error message block?

  11. #10
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,225
    Thanks
    176
    Thanked 817 Times in 760 Posts
    Blog Entries
    5

    Default Re: CompareToIngnore case problem

    Lets please stay on subject and give one another a bit of respect. Personal attacks of any nature will not be tolerated. I am locking this thread as the original problem seems to have been addressed.
    Last edited by copeg; November 7th, 2010 at 04:30 PM.

  12. The Following 2 Users Say Thank You to copeg For This Useful Post:

    Darryl.Burke (November 7th, 2010), javapenguin (January 11th, 2011)

Similar Threads

  1. wanting to convert printout to UPPER case
    By welikedogs in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 3rd, 2010, 01:22 PM
  2. [SOLVED] upper case
    By andaji in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 13th, 2010, 10:54 PM