check for null charecter in a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rakesh005
    New Member
    • Apr 2010
    • 6

    check for null charecter in a string

    how to count the number of charecter in a string without using any inbuilt function in java?
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Use a for loop to traverse the string. Are you considering charAt an inbuilt Java function, or are you only referring to length?

    Comment

    • rakesh005
      New Member
      • Apr 2010
      • 6

      #3
      Originally posted by jkmyoung
      Use a for loop to traverse the string. Are you considering charAt an inbuilt Java function, or are you only referring to length?
      yes i am considering charAt an inbuilt Java function.
      using the charAt and length function can do the program, i want to know can we use array index value for string operation?

      Comment

      • pbrockway2
        Recognized Expert New Member
        • Nov 2007
        • 151

        #4
        i want to know can we use array index value for string operation?
        No, you cannot. A string is a string and has string methods etc, an array is an array and has array methods etc.

        It might have been easier just to ask that question.

        Why do you not want to use "built in" methods? They are built in so that you can use them. Not using builtin methods leaves you with just using arithmetic and other operators and assigning the results to things but that's about it: a sort of leaf-falling-from-a-tree-in-a-forest-unobserved situation.

        As regards the "null" character (do you mean zero?): this has nothing to do with the number of characters in a string in Java. That is, strings are not terminated in any special way.

        Comment

        • jkmyoung
          Recognized Expert Top Contributor
          • Mar 2006
          • 2057

          #5
          If you can't use any inbuilt functions then you can not really use the class. Even the constructor is an inbuilt function. You'll have to build your own String class.

          Comment

          Working...