0% found this document useful (0 votes)
11 views2 pages

String Methods

Uploaded by

athravasade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

String Methods

Uploaded by

athravasade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment 6B

Aim – Program on 2D array , string functions

Program -

import java.lang.String;
public class strm
{
public static void main(String args[])
{
//String length
String s = "Java is object oriented programming ";
System.out.println("String length = "+s.length());

//String concatenation
String s1 ="Java";
String s2 ="Programming";
System.out.println("String Concatenation 1 = "+(s1+s2));
System.out.println("String Concatenation 2 = "+s1.concat(s2));

//String CharAt
System.out.println("\n String CharAt(1) : "+s1.charAt(1));
System.out.println("\n String CharAt(6) : "+s.charAt(6));

//CompareTo
System.out.println("CompareTo Result = "+s1.compareTo(s2));
System.out.println("CompateTO Result = "+s2.compareTo(s1));

//contains
System.out.println("\n Java is a object oriented Programming "+ s.contains(s1));
System.out.println("\n Java is a objet oriented programming "+ s.contains(s2));

//indexof()
System.out.println("\n Index of 'o' is "+s.indexOf('o'));

//equals()
System.out.println("\n String first and second are equal = "+s.equals(s2));

//lower and upper case


String s3 = "INHERITANCE";
System.out.println("\n Upper case of String 1 = "+s1.toUpperCase());
System.out.println("\n Lower case of String 3 = "+s3.toLowerCase());

}
Experiment 6B

Output -

You might also like