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

Package Public Class Public Static Void: 'R' 'A' 'S' 'A' 'G' 'N' 'A'

The document contains code examples demonstrating different string methods in Java including initializing a string from a character array, converting a string to uppercase, checking if a string contains a substring, checking if a string ends with a substring, getting the length of a string, getting uppercase characters from a string, extracting substrings, and concatenating substrings with parts converted to uppercase.

Uploaded by

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

Package Public Class Public Static Void: 'R' 'A' 'S' 'A' 'G' 'N' 'A'

The document contains code examples demonstrating different string methods in Java including initializing a string from a character array, converting a string to uppercase, checking if a string contains a substring, checking if a string ends with a substring, getting the length of a string, getting uppercase characters from a string, extracting substrings, and concatenating substrings with parts converted to uppercase.

Uploaded by

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

package com.cg.

strings;

public class StringEx1 {


public static void main(String[] args) {

// 1.
char ch[]= {'R','A','S','A','G','N','A'};
String S1=new String(ch);
System.out.println(S1);

// 2.
String S="java standard edition";
S=S.toUpperCase();
System.out.println(S);

// 3.
String A="Archana and Rasagna";
String B="and";
System.out.println(A.contains(B));

//4.
String C="Archana";
String D="Rasagna";
String end_str="na";
boolean ends1=C.endsWith(end_str);
boolean ends2=C.endsWith(end_str);
System.out.println("\"" + C + "\" ends with " +"\"" + end_str + "\"? " + ends1);
System.out.println("\"" + D + "\" ends with " +"\"" + end_str + "\"? " + ends2);

// 5.
System.out.println(C.length());

// 6.
String E = "Im Akuthota Rasagna";
for (int i = 0; i < E.length(); i++) {
if (Character.isUpperCase(E.charAt(i))) {
System.out.println(E.charAt(i));}
}
// 7.
String F = "bvrit college";
String sub = F.substring(0, F.indexOf("l") + 1);
String sub1 = F.substring(F.indexOf("l"), F.indexOf("l") + 1);
String sub2 = F.substring(F.indexOf("e"));
System.out.println(sub + sub1.toUpperCase() + sub2);

// 8.
String G = "b.v.raju college";
String H = G.substring(0, 4);
String I = G.substring(4, 8);
String J = G.substring(8);
System.out.println(H + I.toUpperCase() + J);
}}

You might also like