DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5

Thread: quick question

  1. #1
    Join Date
    Oct 2003
    Posts
    12

    quick question

    Dear friends,

    how can i add : ch != ' ' ';
    i tried to use that in the code in order to avoid reading the character ' but it didn't work....any idea

    Code:
      for(int k= 0; k < wordsarr[i].length(); k++)
           {  
               ch = wordsarr[i].charAt(k) ;
               
               if(ch != ';' && ch != ',' && ch != '"' && ch != '-' )
               {
                   copywords[i] =    copywords[i] + ch ;
               }
    [ArchAngel added CODE tags]

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    In future, it helps us if you post any compiler or runtime errors you get.

    You need to "escape" the sybol by preceding it with a back slash:
    Code:
    public class Test {
            public static void main(String[] args) {
                    char c1 = 'a';
                    if (c1 != '\'') {
                            System.out.println("Not '!");
                    }
            }
    }
    ArchAngel.
    O:-)

  3. #3
    Join Date
    Oct 2003
    Posts
    12
    you can not write
    if (c1 != ''')

    if i write c1 = '''; it gives an error that says "empty character literal" so i want to use the unicode for ' to avoid the problem. what is the unicode for '

    thanks

  4. #4
    Join Date
    Mar 2003
    Posts
    834
    The forum keeps getting rid of my extra backslash. I've worked out how to keep it now:
    Code:
    public class Test {
            public static void main(String[] args) {
                    char c1 = 'a';
                    if (c1 != '\\'') {
                            System.out.println("Not '!");
                    }
            }
    }
    ArchAngel.
    O:-)

  5. #5
    Join Date
    Oct 2003
    Posts
    12
    Now it works nicely ...............many thanks for your efforts.




    thanks a lot

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links