Skip to main content

CharAt() method & setCharAt() method in JAVA.

CODING:
class charat
{
  public static void main(String args[])
   {
      StringBuffer s =new StringBuffer("Programming Example");
      char s1= s.charAt(8);
      System.out.println("Before String:" + s);
      System.out.println("Before changed 8th position in String:" + s1);
      s.setCharAt(8,'X');
      System.out.println("After changed 8th position in String :" + s);
   }
}

Comments