Please explain the two for-loops in detail.
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
Please explain the two for-loops in detail.
![|import java.util.*;
public class Example {
public static void main(String[] args) {
String name = "John Matthew Adams";
System.out.println("The full name is: " + name);
System.out.print("Initials with surname is: ");
int len = name.length();
name = name.trim();
String str1 = "";
0; i < len; i++) {
for (int i
char ch = name.charAt(i);
if (ch != ' ') {
stri
stri + ch;
} else {
System.out.print(Character.toUpperCase(str1.charAt(0)) + ". ");
stri = "";
}
}
String str2 = "";
%3D
for (int j = 0; j < str1.length(); j++) {
if (j
str2 = str2 + Character.toUpperCase (str1.charAt(0));
0)
==
%3D
else
str2
str2 + Character.toLowerCase(str1.charAt(j));
}
System.out.println(str2);
}
}
Output
The full name is: John Matthew Adams
Initials with surname is: J. M. Adams](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2c5d7cca-51e3-4cb6-bf10-0b3316d7fed6%2Fc108861e-25b4-4da0-94a5-a52f96c8e71b%2Fcvrz6wk_processed.png&w=3840&q=75)

Step by step
Solved in 3 steps with 1 images









