[go: up one dir, main page]

0% found this document useful (0 votes)
1 views1 page

String Operations

The document is a Java program that demonstrates basic string operations such as concatenation, searching for a substring, and extracting a substring. It concatenates two strings, checks for the presence of a substring in a main string, and extracts a portion of the main string. However, the code contains several syntax errors that would prevent it from compiling successfully.

Uploaded by

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

String Operations

The document is a Java program that demonstrates basic string operations such as concatenation, searching for a substring, and extracting a substring. It concatenates two strings, checks for the presence of a substring in a main string, and extracts a portion of the main string. However, the code contains several syntax errors that would prevent it from compiling successfully.

Uploaded by

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

public class StringOperations

{
public static void main(String[]args)
{
String str1="Hello";
String str2="World";
String concatenatedString=str1+""+str2;
System.out.println((oncatenated String;"+concatenatedString);
string mainString="Hello Woeld,Welcome to Java!";
String substringToSearch="World";
int index=mainString.indexOf(substring ToSearch);
if(index!=-1)
{
System.out.println("Substring'"=substringTosearch+"'found at index:"+index);
}
else
{
System.out.println("Substring'"+substringToSearch+"'notfound.");
}
int startIndex=6;
int eendIndex=11;
String exractedSubstring=mainString.substring(startIndex,endIndex);
System.out.print("Extracted Substring:"+extractedSubstring);
}
}

You might also like