/** * Name: Erica Eddy * Course: CSCI 145/241 - Computer Science I * Section: 001 or 002 * Assignment: 1 */ public class SBExamples { public static void main (String [] args) { StringBuilder spring = new StringBuilder("spring"); System.out.println("spring = " + spring); // replace the character at position 5 with a 't' spring.setCharAt(5,'t'); System.out.println("After setCharAt, spring = " + spring); // add the word " ahead" at the end of the current StringBuilder spring.append(" ahead"); System.out.println("After append, spring = " + spring); // place other words in front of what is already in // the StringBuilder spring.insert(0,"I hate when I have to "); System.out.println("After insert, spring = " + spring); StringBuilder newSb = spring.append("!"); System.out.println("spring = " + spring); System.out.println("newSb = " + newSb); if (spring == newSb) System.out.println("spring and newSb refer to the same object"); else System.out.println("spring and newSb refer to different objects"); } }