This website provides a wide range of educational resources, tools, and features to enhance your learning experience.
Friday, August 30, 2024
Javamy
import java.lang.*;
class STR {
// Function to insert string
public static String insertString(
String originalString,
String stringToBeInserted,
int index) {
// Create a new string
String newString = new String();
for (int i = 0; i < originalString.length(); i++) {
// Insert the original string character
// into the new string
newString += originalString.charAt(i);
if (i == index) {
// Insert the string to be inserted
// into the new string
newString += stringToBeInserted;
}
}
// return the modified String
return newString;
}
// Driver code
public static void main(String[] args) {
String originalString = "Hello, world!";
String stringToBeInserted = " there";
int index = 6;
String modifiedString = insertString(originalString, stringToBeInserted, index);
System.out.println("Modified string: " + modifiedString);
}
}
Subscribe to:
Post Comments (Atom)
New Post
Javamy
import java.lang.*; class STR { // Function to insert string public static String insertString( String originalString, ...
-
class 9 Biolog chapter 1 ⇩ The fundamental unit of life : CELL The cell is basic structural and functional unit of living ...
-
Ozone⏩ ⏩Ozone is a ligh t b luish gas found in the upper layer of atmosphere (stratosphere). ⏩Ozone is formed by the action...
-
Class 9 Physics Chapter 3 GRAVITATION The Force with which the earth pulls the objects toward it is...
No comments:
Post a Comment
please do not enter any spam link in the comment .