Strings

  • Write a line of code to use the String’s substring() method to obtain the substring "lip" from a String instance named s that is set to "tulip".
"s.substring(2, 5)" or "s.substring(2)" or "s.substring(2, s.length())";

  • Only + and += are overloaded for String objects
  • The method substring() starts at the first index, inclusive, with 0 being the first character), and ends at the end index -1 (that is, exclusive of the end index).
  • The StringBuffer class does not override equals(). Hence, the code below returns false when passed two different objects.
StringBuffer sb1 = new StringBuffer("hello");
StringBuffer sb2 = new StringBuffer("hello");
if (sb1.equals(sb2))

System.out.println("equal");elseSystem.out.println("not equal");

Comments

Popular posts from this blog

jQgrid reload with new data

Introduction to jQgrid

Rich Client based UI technologies- A Comparison of Thick Client UI tools