/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Anousha */ import java.util.Scanner; public class ReplaceString { public static void main (String [] args) { Scanner scan = new Scanner (System.in); System.out.println ("Please input a text"); // creating an object of String class String txt = scan.nextLine(); // replace method RETURNS a String... therefore you should save it into an object of String class txt = txt.replaceFirst("hate", "love"); System.out.println ("I have rephrased this to be: "); System.out.println (txt); String university = "University of Georgia"; // Printing the university in Upper case letters using the method toUpperCase() System.out.println (university.toUpperCase()); } }