Java String ObjectsString class:java.lang.StringIn Java, strings are constant; their values cannot be changedaftertheyarecreated StringBuffer class: java.lang.StringBufferA string buffer is like a String, but can be modified. At anypoint intime it contains some particular sequence ofcharacters, but the length and content of the sequence canbe changed through certain method calls
Java String Objects ⚫ String class: java.lang.String ⚫ In Java, strings are constant; their values cannot be changed after they are created. ⚫ StringBuffer class: java.lang.StringBuffer ⚫ A string buffer is like a String, but can be modified. At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls
Example: Corporate RenamingCorporate name changes are occurring with ever greaterfrequency, as companies merge, buy each other out, try to hidefrom bad publicity.... These changes make it difficult to figure outthe current name of a company when reading old documents.Your company, Digiscam, has put you to work on a programwhich maintains a database of corporatenames changes anddoes the appropriate substitutionsto bring old documents up todate.Your program should take as input a file with a given number ofcorporate name changes, followed by a given number of lines oftext for you to correct. Only exactmatches of the string shouldbereplaced.There will be at most 1o0 corporate changes, and each line oftext is at most 1,oo0 characters long
Example: Corporate Renaming ⚫ Corporate name changes are occurring with ever greater frequency, as companies merge, buy each other out, try to hide from bad publicity. These changes make it difficult to figure out the current name of a company when reading old documents. ⚫ Your company, Digiscam, has put you to work on a program which maintains a database of corporate names changes and does the appropriate substitutions to bring old documents up to date. ⚫ Your program should take as input a file with a given number of corporate name changes, followed by a given number of lines of text for you to correct. Only exact matches of the string should be replaced. ⚫ There will be at most 100 corporate changes, and each line of text is at most 1,000 characters long
Sample Input and Output"Anderson Consulting"to“"Accenture""Enron"to“Dynegy”"“DEC"to“Compaq”""TWA"to“American”Anderson Accounting begat Anderson Consulting, whichoffered advice to Enron before it DECLAREDbankruptcy,whichmadeAndersonConsulting quite happy it changed its namein thefirst place!Output:AndersonAccountingbegatAccenture,whichoffered advice to Dynegy before it CompaqLAREDbankruptcy,whichmadeAndersonConsulting quite happy it changed its namein the first place!
Sample Input and Output “Anderson Consulting” to “Accenture” “Enron” to “Dynegy” “DEC” to “Compaq” “TWA” to “American” Anderson Accounting begat Anderson Consulting, which offered advice to Enron before it DECLARED bankruptcy, which made Anderson Consulting quite happy it changed its name in the first place! Output: Anderson Accounting begat Accenture, which offered advice to Dynegy before it CompaqLARED bankruptcy, which made Anderson Consulting quite happy it changed its name in the first place!