Home > Back-end >  What is the difference between continue , Break , default in java
What is the difference between continue , Break , default in java

Time:10-31

Could someone help explain to me the differences between these keywords in java?

  • break
  • continue
  • default

CodePudding user response:

Continue:

A continue statement ends program execution of the current iteration of a loop statement but does not stop execution of the loop statement.

Break:

A break statement ends program execution of a loop, an if statement, or a switch statement.

Default:

is an access modifier. If you didn't assign any access modifier to variables, methods, constructors and, classes, by default, it is considered as default access modifier.

CodePudding user response:

break to End the loop or the method
default it's the default value if no condition is true
continue statement breaks one iteration in the loop

reference : https://www.w3schools.com/java/java_break.asp

  •  Tags:  
  • java
  • Related