Sunday, 20 November 2022

String - Exercise 1

 String - Exercise 1


Complete the removeWhiteSpaces() method given in the Tester class.

Method Description

removeWhiteSpaces(String str)

  • Remove all the white spaces from the string passed to the method and return the modified string.

Test the functionalities using the main() method of the Tester class. 

 

Sample Input and Output


class Tester{

public static String removeWhiteSpaces(String str){
String noSpaceStr=str.replaceAll("\\s","");//usingbuiltinmethod
//Implementyourcodehereandchangethereturnvalueaccordingly
return noSpaceStr;
    }
   
    public static void main(String args[]){
        String str = "Hello   How are you   ";
        str = removeWhiteSpaces(str);
        System.out.println(str);
    }
}

coding savior,infosys assignment quiz and lex genrric ansewer,infosys generic java program, code answer,code saviour,code monk,coding bar,code solution for infosys  assignmenet,code saviour trend




No comments:

Post a Comment

Free Resume Template

Creating a blog post that discusses the pros and cons of using a resume rule is a great way to provide valuable information to job seekers ...