Results 1 to 5 of 5
  1. #1
    pauser is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

    Question countin unique chars !

    Hi everyone !
    Im new in this forum!

    Im having a problem. I want to count the unique characters of a String(Ascii Image) without using Arrays .
    I've already tried this, but no result :S .

    PHP Code:
    public int getUniqueChars(){
    	String imgchar = Image; //Image is the original asciiImage
    	for(int i=0;i<imgchar.length();i=i+0){
    		imgchar=imgchar.replaceAll(Character.toString(imgchar.charAt(i)),"");
    		}
    		imgChars = imgchar.length();
    	return imgChars;
    	}

  2. #2
    pauser is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

    Default

    Help help help please !!!

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You've bumped your thread after it's been here for only an hour. Please read this link to see why this may have the opposite effect you intended: PatienceIsAVirtue

  4. #4
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Quote Originally Posted by pauser View Post
    PHP Code:
    	for(int i=0;i<imgchar.length();i=i+0){
    It's gonna take a while for i to get to imgchar.length when it's advancing zero characters at a time.

    -Gary-

  5. #5
    pauser is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

    Default

    I found the solution :D . Sorry, i could not wait :S.
    PHP Code:
    public int getUniqueChars(){
    
    		
    
    	String imgchars = "";
    
    	for(int i=0;i<Image.length();i++){
    
    		if(!imgchars.contains(Character.toString(Image.charAt(i))))
    
    			imgchars += Character.toString(Image.charAt(i));
    
    		}
    
    	return imgchars.length();
    
    	}

Similar Threads

  1. find the unique values of a double array
    By tyang in forum New To Java
    Replies: 3
    Last Post: 09-11-2011, 02:47 PM
  2. Replies: 2
    Last Post: 02-18-2010, 05:26 PM
  3. Generate unique letters
    By bl00dr3d in forum New To Java
    Replies: 22
    Last Post: 04-10-2009, 02:44 PM
  4. Unique Filter on search results
    By selva in forum Lucene
    Replies: 0
    Last Post: 02-17-2009, 07:32 AM
  5. Unique element in an array
    By revathi17 in forum New To Java
    Replies: 2
    Last Post: 12-31-2007, 08:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •