Question: public class Substrings { public static void main(String[] args) { String str = Programming in Java is fun!; // your code goes here } }
public class Substrings { public static void main(String[] args) { String str = "Programming in Java is fun!"; // your code goes here } }
/* a. Extract the second word in the string using the .substring() method. */ String sub1 = "Replace this text with your answer."
/* b. Extract the last word in the string, but not the punctuation, using the .substring() method. */ String sub2 = "Replace this text with your answer."
/* c. Extract the word Java in the middle of the string using the .substring() method. */ String sub3 = "Replace this text with your answer."
/* d. Extract all but the first character of the string using the .substring() method. */ String sub4 = "Replace this text with your answer."
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
