Page 1 of 1

What is the output of the program please answer with full explanation String str = “Java”; for (int i = 0; i < str.lengt

Posted: Fri Jul 01, 2022 5:34 am
by answerhappygod
What is the output of the program please answer with full explanation
String str = “Java”;
for (int i = 0; i < str.length(); i++) {
char x = str.charAt(i);
int y = 1;
for (int j = 0; j < str.length(); j++) {
if (str.charAt(j) == x && i != j) {
y++;
}
}//end of for loop (inner) System.out.println(x+ ">" + y);
}//end of for loop (outer)
please answer with full explanation
i need explanation
What Is The Output Of The Program Please Answer With Full Explanation String Str Java For Int I 0 I Str Lengt 1
What Is The Output Of The Program Please Answer With Full Explanation String Str Java For Int I 0 I Str Lengt 1 (44.92 KiB) Viewed 28 times
Q2. [6 marks] Trace the following Java code by writing the output 1. [2 marks] What is the output of the following program String str="Java"; for (int i = 0; i <str.length(); i++) { char x = str.charAt(i); int y = 1; for (int j = 0; j<str.length(); j++) { if (str.charAt(j) ==x && i !=j) { y++; } }//end of for loop (inner) System.out.println(x +""+y); }//end of for loop (outer) Output below: ***************** ********* **************