Converting loops (Java Beginner question)

前端 未结 5 427
独厮守ぢ
独厮守ぢ 2020-12-20 06:45

Does Converting between loops always works like this? or there is some situation that it does not? and what is the fastest way to check while I\'m solving a question like th

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-20 07:26

    // This class demonstrates the transliteration
    // between while, for, and for-each loop syntax
    public class LoopTest {
    
        // This method definition showcases do-while-loop syntax 
        public void doWhileLoop(Person[] people) {
            int i=0;
            do {
                Person p = people[i];
                System.out.println(p.getName());
                i++;
            }while(i

提交回复
热议问题