To find number of character without space using java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sunmat
    New Member
    • Jul 2007
    • 1

    To find number of character without space using java

    To find number of character without space using java

    Example:
    String = prabu sun
    No. of char =8

    plz send me code
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by sunmat
    To find number of character without space using java

    Example:
    String = prabu sun
    No. of char =8

    plz send me code
    No one is going to write it for you.
    Read the java docs and see the methods in the String and Character classes.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by sunmat
      To find number of character without space using java

      Example:
      String = prabu sun
      No. of char =8

      plz send me code
      You could turn it around: "find the number of spaces in a string". Counting all
      characters in a String is solved already, i.e. the String class has a length() method.

      kind regards,

      Jos

      Comment

      • praveen2gupta
        New Member
        • May 2007
        • 200

        #4
        Originally posted by sunmat
        To find number of character without space using java

        Example:
        String = prabu sun
        No. of char =8

        plz send me code
        Hi
        Do it as follows
        1. declare a string variable.
        2. assign the value to the variable.
        3. use varable.length( ) to count the length. The space will be counted by this method.

        Comment

        Working...