Don't use do-while loop in Payment system - Said lecturer

183 views   Programming  2021.01.05

But I don't think do When I was studying in university @Level2 I acquired some logics behind Loops when we were learning OOP in Java. Our lecturer warned us and said 'Never use do-while loop just because it performs whatever while-loop can do. What if you want to make a condition to give money to someone? - with do-while loop tech, The system will give money to client then check his pin or password after - then he went on... saying this 'Do you think do-while-loop is good at that job? Most of us, said - We will use while-loop forever. What do you think about this devs, Tell us what do you think about this statement! Happy coding!

Answers, ideas and Comments

» 1 idea

codeveloper • 10 months ago
I think do-while-loop is not always bad, but depending on what you want to perform before and after given condition. As far as I can understand what you meant your you mean something like this.

// Here action will be performed first 
// and then condition checked after.
// As do-while-loop works. 

do {
System.out.println("Money withdrawn successfully");
} while (Balance >= RequestedMoney);



In order to go deep, share any relevant idea or posting solution to some questions, You have to sign in or create a new account if you don't have one. And get Donnekted(connected)

Log in now  Join the Team

This site is for sharing topics, questions, answers, experiences or other contents related to different stuffs, especially technology. For existing users, They can make any topic(post) to discuss about in hope for ideas or any result from other people from different communities. In order to get involved, Get donnekted(connected) by Joining us here!