0% found this document useful (0 votes)
6 views

11 Java

This document describes a Java programming experiment on string functions. The code defines several string variables and demonstrates various string methods like length(), concat(), replace(), equals(), compareTo(), toUpperCase(), toLowerCase(), charAt() on the string variables. It outputs the results of applying each string function to understand their behavior in Java.

Uploaded by

Ganesh Ekambe
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

11 Java

This document describes a Java programming experiment on string functions. The code defines several string variables and demonstrates various string methods like length(), concat(), replace(), equals(), compareTo(), toUpperCase(), toLowerCase(), charAt() on the string variables. It outputs the results of applying each string function to understand their behavior in Java.

Uploaded by

Ganesh Ekambe
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Java Programming

Name of Student: Ekambe Ganesh Roll No.: 88

Experiment No.: 11 DOS:

CODE:

class string2
{
public static void main(String args[])
{

String str1= "java";


System.out.println("first string:" + str1);
System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

String str2= "program";


System.out.println("second string:" + str2);
System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

String str3= "Gramin polytechnic Nanded";


System.out.println("third string:" +str3);
System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

String str4= "Java";


System.out.println(" fourth string: " +str4);
System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

String str5= "Gramin";


System.out.println(" fifth string: " +str5);
System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");
Java Programming
System.out.println(" string function: 1");
System.out.println("**length of string**");
System.out.println("length of String1= java: " +str1.length());
System.out.println("length of String2:=program: " +str2.length());

System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

System.out.println(" string function: 2");


System.out.println("**concatnation of string**");
System.out.println("concat of String java & program: " +str1.concat(str2));

System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

System.out.println(" string function: 3");


System.out.println("**replace of string**");
System.out.println("replace of String1 java to c++: " +str1.replace ("java","c+
+"));
System.out.println("replace of String2 program to python: " +str2.replace
("program","python"));

System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

System.out.println(" string function: 4");


System.out.println("**equls of string**");
System.out.println("equals of String1 java & programs: " +str1.equals(str2));

System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

System.out.println(" string function: 5");


System.out.println("**compare of string**");
System.out.println("compare of String java & program: "
+str1.compareTo(str2));

System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

System.out.println(" string function: 6");


System.out.println("**remove of space of string**");
str3 = str3.replaceAll("\\s+", "");
System.out.println("String after removing all the white spaces : " + str3);
Java Programming

System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

System.out.println(" string function: 7");


System.out.println("**Upper case of string**");

System.out.println("after uppercase of String5 Gramin: "


+str5.toUpperCase());

System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

System.out.println(" string function: 8");


System.out.println("**LOwer case of string**");
System.out.println("after lowercase of String5: Gramin:" +str5.toLowerCase());

System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

System.out.println(" string function: 9");


System.out.println("equals ignore case");
System.out.println(" " +str1.equalsIgnoreCase(str4));

System.out.println(" * * * * * * * * * * * * * * * * * * * * * * *");

System.out.println(" string function: 10");


System.out.println("char at function");
System.out.println("String:Hello");
System.out.println("find the location of H");

String myStr = "Hello";


char result = myStr.charAt(2);
System.out.println(result);

}
}
Java Programming

OUTPUT
Java Programming

You might also like