atSymbolIndex Correct atSymbolIndex The indexOf method got the index of If

Atsymbolindex correct atsymbolindex the indexof

This preview shows page 2 - 4 out of 4 pages.

atSymbolIndexCorrectatSymbolIndexThe indexOf() method got the index of @. If found (i.e. not -1), then that index was used to indicate the size of the substring preceding the @. So for [email protected], the @ is at index 10, which is the number of letters in AbeLincoln. Thus, substring() starts at index 0 and gets 10 characters, namely "AbeLincoln".PARTICIPATIONACTIVITY3.12.2: String modification methods.str1 is "Main" and str2 is " Street" (note the leading space).1)Use + to combine str1 and str2, so newStr should be "Main Street".newStr = str1+ str2 ;Correct+ str2 + appends str2 to str1 in a new string.2)Use concat to append a period to str2, so str2 should be " Street."str2 = str2.concat(".");Correctconcat(".")The concat method creates new string with "." appended str2.3)Replace "ai" with "our" in str1, so str1 should be "Mourn".str1 = str1.replace("ai", "our");Correctreplace("ai", "our")Creates a new String in which all occurrences of "ai" are replaced with "our".
Background image
CHALLENGEACTIVITY3.12.1: Combining strings.Assign secretID with firstName, a space, and lastName. Ex: If firstName is Barry and lastName is Allen, then output is:Barry Allenimport java.util.Scanner;public class
Background image
Image of page 4

You've reached the end of your free preview.

Want to read all 4 pages?

  • Summer '18
  • Java Programming, Void type, Replacements, Index Librorum Prohibitorum, songVerse

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture