This commit is contained in:
2024-11-20 01:42:50 +03:00
parent 95ebce05ed
commit 0d3b7bf545
5 changed files with 120 additions and 0 deletions

21
labs/lab3/StringPlay.java Normal file
View File

@ -0,0 +1,21 @@
// **************************************************
// StringPlay.java
//
// Play with String objects
// **************************************************
public class StringPlay
{
public static void main (String[] args)
{
String college = new String ("PoDunk College");
String town = new String ("Anytown, USA"); // part (a)
int stringLength;
String change1, change2, change3;
stringLength = college.length(); // part (b)
System.out.println (college + " contains " + stringLength + " characters.");
change1 = college.toUpperCase(); // part (c)
change2 = change1.replace("O","*"); // part (d)
change3 = college.concat(", ").concat(town); // part (e)
System.out.println ("The final string is " + change3);
}
}