Homework Solution: Retype and correct the code provided to combine two strings separated by a space. secret ID. contact (spaceChar): secret ID. contact (lastName): 1 im…

    @@@ < >肛 learn.zybooks.com ○山。 Lab 2 Post Test: COMPUTER SCIENCEICSC Computer Sclence question Chegg.com 3.9. String modify operations uava浂于初蛤化boolean值的问题百度知道 响 chegg Study l Gulded Solutions and Study- zyBooks Library>CSCE 155A home >3.9:String modify operations @ Help/ FAQ θ BojunZhong ▼ 搜索 ☆个人收藏 CHALLENGE3,9.1: Combining strings. ACTIVITY IMG 0264.JPG 4-5学生选课 添加课程11 (0 F22BB179-E979-46F2-AAO9... 20E74856-C898-4889-85A Retype and correct the code provided to combine two strings separated by a space. secretID.concat (spaceChar) secretID.concat (lastName); 1 import java.util.Scanner; 3 public class CombiningStrings f 4 public static void main (String args) [ String secretIDBarry; String lastName Allen char spaceChar secretID.concat(spaceChar) 10 secretID.concat(lastName); 12 13 14 15 System.out.println(secretID); return; Failed to compile CombiningStrings.java:9: concat (java.lang.String) in java.lang.String cannot be applied to (char)
    Retype and correct the code provided to combine two strings separated by a space. secret ID. contact (spaceChar): secret ID. contact (lastName): 1 important java.util.Scanner { 2 3 public class CombiningStrings { 4 public static void main (String argus) { 5 String secretID = "Barry" 6 String lastName = "Allen": 7 char spaceChar = ' ': 8 9 secretID.concat(spaceChar): 10 secretID.concat(lastName): 11 System.Out.Println (secretID): 13 return: 14 } 15 }

    Expert Answer

     
    import java.util.Scanner;

    @@@ < >肛 glean.zybooks.com ○山。 Lab 2 Post Test: COMPUTER SCIENCEICSC Computer Sclence investigation Chegg.com 3.9. String change operations uava浂于初蛤化boolean值的问题百度知道 响 chegg Study l Gulded Solutions and Study- zyBooks Library>CSCE 155A home >3.9:String change operations @ Help/ FAQ θ BojunZhong ▼ 搜索 ☆个人收藏 CHALLENGE3,9.1: Combining strings. ACTIVITY IMG 0264.JPG 4-5学生选课 添加课程11 (0 F22BB179-E979-46F2-AAO9... 20E74856-C898-4889-85A Rekind and rectify the enactment granted to integrate span strings disjoined by a immeasurableness. retiredID.concat (spaceChar) retiredID.concat (lastName); 1 significance java.util.Scanner; 3 common systematize CombiningStrings f 4 common static wanting deep (String args) [ String retiredIDBarry; String lastName Allen char immeasurablenessChar retiredID.concat(spaceChar) 10 retiredID.concat(lastName); 12 13 14 15 System.out.println(secretID); return; Failed to write CombiningStrings.java:9: concat (java.lang.String) in java.lang.String cannot be applied to (char)

    Rekind and rectify the enactment granted to integrate span strings disjoined by a immeasurableness. retired ID. touch (spaceChar): retired ID. touch (lastName): 1 significanceant java.util.Scanner { 2 3 common systematize CombiningStrings { 4 common static wanting deep (String argus) { 5 String retiredID = “Barry” 6 String lastName = “Allen”: 7 char immeasurablenessChar = ‘ ‘: 8 9 retiredID.concat(spaceChar): 10 retiredID.concat(lastName): 11 System.Out.Println (secretID): 13 return: 14 } 15 }

    Expert Reply

     

    significance java.util.Scanner;
    common systematize IntegrateStrings
    {
    common static wanting deep(String args[])
    {
    String retiredID=”Barry”;
    String lastName=”Allen”;
    String spaceChar=” “;                    //we accept to make spaceChar a String because by concat(),we can concatenate Strings only
    secretID=secretID.concat(spaceChar);        // it allure concatenate spaceChar with secretID
    secretID=secretID.concat(lastName);           // it allure concatenate lastName with secretID
    System.out.println(secretID);              // it allure stereokind the rate of secretID
    }
    }

    OUTPUT OF THIS CODE IS :

    NOTE : A character rate can’t be concatenated by concat() with a String kind Rate.That’s why we made spaceChar variable as a String so that we can largely concatenate it with secretID