Skip to main content

Home/ Cohort 21 Shared Resources/ Contents contributed and discussions participated by agregson

Contents contributed and discussions participated by agregson

agregson

String (Java Platform SE 7 ) - 1 views

  • str =
    • agregson
       
      This is a reference to an object of type String
  • "abc"
    • agregson
       
      This is a String literal; Java allows us to initialize strings this way rather than use the constructor: String str = new String("abc");
  • String()
  • ...5 more annotations...
  • charAt(int index)
    • agregson
       
      This method allows you to access a String as if it were a char array; note that there is no "set" method, since strings are immutable.
  • int indexOf(int ch, int fromIndex) Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index. int indexOf(String str) Returns the index within this string of the first occurrence of the specified substring. int indexOf(String str, int fromIndex) Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
    • agregson
       
      Very useful for string processing.
  • split(String regex)
    • agregson
       
      This method is very useful!  If you don't know what a regular expression is, try splitting around " " (a single space) or ",' (a comma).  It will save you much time when reading in data. 
  • String substring(int beginIndex) Returns a new string that is a substring of this string. String substring(int beginIndex, int endIndex) Returns a new string that is a substring of this string.
    • agregson
       
      Commonly used for string processing, in concert with indexOf()
  • trim()
    • agregson
       
      Useful when trying to determine if strings are equal.
1 - 3 of 3
Showing 20 items per page