Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals of Software Development ISlide 1 Recap: Key ideas in WordGames ClassClass –versus instances –Defining –use of fields –Constructors E.g., to.

Similar presentations


Presentation on theme: "Fundamentals of Software Development ISlide 1 Recap: Key ideas in WordGames ClassClass –versus instances –Defining –use of fields –Constructors E.g., to."— Presentation transcript:

1 Fundamentals of Software Development ISlide 1 Recap: Key ideas in WordGames ClassClass –versus instances –Defining –use of fields –Constructors E.g., to initialize fieldsE.g., to initialize fields Extending a class versus implementing an interfaceExtending a class versus implementing an interface Methods, parameters and local variablesMethods, parameters and local variables We reviewed almost all of these ideas in Session 11! Blocks and scopeBlocks and scope Declaring variablesDeclaring variables ExpressionsExpressions StatementsStatements –Assignment –Conditionals –Blocks –Loops (now) Except for this one …

2 Fundamentals of Software Development ISlide 2 Loops A loop is: a block of code that executes repeatedly while some condition holds true.a block of code that executes repeatedly while some condition holds true. while (condition) { statement; … statement; } for (start; condition; step) { statement; … statement; } do { statement; … statement; } while (condition); while loop for loop do-while loop

3 Fundamentals of Software Development ISlide 3 Loops solve a problem How to write code to do things which we want to repeat! … like:How to write code to do things which we want to repeat! … like: Scanner inputStream = new Scanner(System.in); double input; input = inputStream.nextDouble(); while (input >= 0) { System.out.println(input*input); input = inputStream.nextDouble(); } Question: Could you do this one without loops? Depends on the type of variable you want to read!


Download ppt "Fundamentals of Software Development ISlide 1 Recap: Key ideas in WordGames ClassClass –versus instances –Defining –use of fields –Constructors E.g., to."

Similar presentations


Ads by Google