0
for loop?
Why the latest number is 2 & also why they are not equal x<x*x; or x<36; ? package com.example.myapplication; public class Test { public static void main(String[] args) { int i; for(i=6; i<i*i; --i){ System.out.print(i); } } }
2 Answers
+ 3
When i is 1 it is no longer less than i*i since 1*1=1. So the loop condition is no longer true.
I don't understand the second part of your question.
+ 2
For(initialization; condition; iteration)
Your initialization is "i = 6" but your condition becomes false when I is equal to 1
"x<x*x" means that x is less that itself raised to the power of 2 but
"x<36" means that x is less that 36 which can also be that condition for this your code as long as you are not gonna go above "I = 35"