Sunday, November 17, 2019

String operations using Java


  • Program :
import java.io.*;
public class Operation
{
public static void main(String args[])
{
String s1="Ram";
String s2="Kannan is a good boy";
System.out.println("String length:"+s1.length());
System.out.println(s1.compareTo(s2));
s1=s1.concat("hello");
System.out.println(s1);
System.out.println(s1.isEmpty());
System.out.println(s1.trim+"how are you");
String s1lwr=s1.toLowerCase();
System.out.println(s1lwr);
String s1upr=s1.toUpperCase();
System.out.println(s1upr);
System.out.println(s1.equalsIgnoreCase(s2);
String rplcstr=s1.replace('R', 'T');
System.out.println(rplcstr);
System.out.println(s1.contains("kannan"));
}
}

2 comments:

Function Overloading in C++

https://monitechvenkat1620.blogspot.com Program : #include <iostream> using namespace std; int c(int x, int y) {   return...