In this video, Doug Winnie shows how to create a while and do while loop in Java. He also introduces the modulo operator (%) that returns the remainder after attempting division. The increment operator is also introduced (++) that increases a variable value by 1.
- [Instructor] In Java we can create a while loop…using the while statement.…In a while loop we need to create a condition…that needs to remain true for the loop to execute.…First, let's create a value to test within the loop.…We'll create an integer called myValue,…and we'll set that equal to zero.…Our loop will go through each integer…from zero to 99 and find all the numbers…that are evenly divisible by nine.…First, we start with the while statement.…Then, we create our condition test that will need…to be true for the loop to continue.…
Since we're testing from zero to 99,…we'll ask if my value is less than 100.…Then we create the body of our loop using a curly brace.…Inside of this we're going to use…a new mathematical operator called the modulo operator.…Modulo takes a value and divides it by another number.…If there is a remainder, it returns that number.…For instance, if we try to divide nine by nine…it divides evenly, so the result is zero.…
If we tried to divide 10 by nine,…the result is one since after you attempt to divide nine…
- The history of Java
- Setting up your development environment
- Working with values and variables
- Using methods and functions
- Capturing user input
- Creating conditional tests
- Using loops
- Creating and changing arrays
- Object-oriented programming in Java
- Defining permissions
- Extending classes
Skill Level Beginner
Java Essential Training for Studentswith Peggy Fisher3h 6m Intermediate
Computer Science Principles: The Internetwith Doug Winnie59m 30s Beginner
1. Intro to Java
2. Define Actions Using Code
3. Repeat Actions and Test for Conditions
4. Object-Oriented Programming Basics
Next steps1m 44s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.