Enviar pesquisa
Carregar
02 prepcode
•
Transferir como PPTX, PDF
•
1 gostou
•
534 visualizações
P
Program in Interdisciplinary Computing
Seguir
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 13
Baixar agora
Recomendados
Loops in JavaScript
Loops in JavaScript
Florence Davis
Java loops
Java loops
ricardovigan
Demystifying functional effect systems in Scala
Demystifying functional effect systems in Scala
Dmitry Karlinsky
Loops
Loops
Kulachi Hansraj Model School Ashok Vihar
Concurrency with side-effects – cats way
Concurrency with side-effects – cats way
stasimus
Loops in c programming
Loops in c programming
CHANDAN KUMAR
Iteration Statement in C++
Iteration Statement in C++
Jaypee Institute of Information Technology
Looping and Switchcase BDCR
Looping and Switchcase BDCR
beriver
Recomendados
Loops in JavaScript
Loops in JavaScript
Florence Davis
Java loops
Java loops
ricardovigan
Demystifying functional effect systems in Scala
Demystifying functional effect systems in Scala
Dmitry Karlinsky
Loops
Loops
Kulachi Hansraj Model School Ashok Vihar
Concurrency with side-effects – cats way
Concurrency with side-effects – cats way
stasimus
Loops in c programming
Loops in c programming
CHANDAN KUMAR
Iteration Statement in C++
Iteration Statement in C++
Jaypee Institute of Information Technology
Looping and Switchcase BDCR
Looping and Switchcase BDCR
beriver
Loops c++
Loops c++
Shivani Singh
Loops in C Programming Language
Loops in C Programming Language
Mahantesh Devoor
Java Exception handling
Java Exception handling
Garuda Trainings
Exceptions in java
Exceptions in java
Manav Prasad
Exceptions in java
Exceptions in java
Rajkattamuri
Loops in c
Loops in c
baabtra.com - No. 1 supplier of quality freshers
Looping in c++
Looping in c++
deekshagopaliya
Testing With Test::Class
Testing With Test::Class
Curtis Poe
Multithreading in java
Multithreading in java
Monika Mishra
Java Concurrency by Example
Java Concurrency by Example
Ganesh Samarthyam
Switch case and looping
Switch case and looping
aprilyyy
exceptions in java
exceptions in java
javeed_mhd
The Loops
The Loops
Krishma Parekh
Introduction+To+Java+Concurrency
Introduction+To+Java+Concurrency
King's College London
Class method object
Class method object
Minal Maniar
Do...while loop structure
Do...while loop structure
Jd Mercado
Different loops in C
Different loops in C
Md. Arif Hossain
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applications
Yura Nosenko
NinjaSynch
NinjaSynch
Thomas Knudstrup
170120107074 looping statements and nesting of loop statements
170120107074 looping statements and nesting of loop statements
harsh kothari
13 interfaces
13 interfaces
Program in Interdisciplinary Computing
Chapter.10
Chapter.10
Program in Interdisciplinary Computing
Mais conteúdo relacionado
Mais procurados
Loops c++
Loops c++
Shivani Singh
Loops in C Programming Language
Loops in C Programming Language
Mahantesh Devoor
Java Exception handling
Java Exception handling
Garuda Trainings
Exceptions in java
Exceptions in java
Manav Prasad
Exceptions in java
Exceptions in java
Rajkattamuri
Loops in c
Loops in c
baabtra.com - No. 1 supplier of quality freshers
Looping in c++
Looping in c++
deekshagopaliya
Testing With Test::Class
Testing With Test::Class
Curtis Poe
Multithreading in java
Multithreading in java
Monika Mishra
Java Concurrency by Example
Java Concurrency by Example
Ganesh Samarthyam
Switch case and looping
Switch case and looping
aprilyyy
exceptions in java
exceptions in java
javeed_mhd
The Loops
The Loops
Krishma Parekh
Introduction+To+Java+Concurrency
Introduction+To+Java+Concurrency
King's College London
Class method object
Class method object
Minal Maniar
Do...while loop structure
Do...while loop structure
Jd Mercado
Different loops in C
Different loops in C
Md. Arif Hossain
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applications
Yura Nosenko
NinjaSynch
NinjaSynch
Thomas Knudstrup
170120107074 looping statements and nesting of loop statements
170120107074 looping statements and nesting of loop statements
harsh kothari
Mais procurados
(20)
Loops c++
Loops c++
Loops in C Programming Language
Loops in C Programming Language
Java Exception handling
Java Exception handling
Exceptions in java
Exceptions in java
Exceptions in java
Exceptions in java
Loops in c
Loops in c
Looping in c++
Looping in c++
Testing With Test::Class
Testing With Test::Class
Multithreading in java
Multithreading in java
Java Concurrency by Example
Java Concurrency by Example
Switch case and looping
Switch case and looping
exceptions in java
exceptions in java
The Loops
The Loops
Introduction+To+Java+Concurrency
Introduction+To+Java+Concurrency
Class method object
Class method object
Do...while loop structure
Do...while loop structure
Different loops in C
Different loops in C
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applications
NinjaSynch
NinjaSynch
170120107074 looping statements and nesting of loop statements
170120107074 looping statements and nesting of loop statements
Destaque
13 interfaces
13 interfaces
Program in Interdisciplinary Computing
Chapter.10
Chapter.10
Program in Interdisciplinary Computing
09 polymorphism
09 polymorphism
Program in Interdisciplinary Computing
Html5
Html5
Program in Interdisciplinary Computing
Javascript2
Javascript2
Program in Interdisciplinary Computing
8 Typography Notes
8 Typography Notes
Program in Interdisciplinary Computing
Web architecture
Web architecture
Program in Interdisciplinary Computing
Destaque
(7)
13 interfaces
13 interfaces
Chapter.10
Chapter.10
09 polymorphism
09 polymorphism
Html5
Html5
Javascript2
Javascript2
8 Typography Notes
8 Typography Notes
Web architecture
Web architecture
Semelhante a 02 prepcode
02 - Prepcode
02 - Prepcode
thewhiteafrican
Java
Java
tintinsan
Reading and writting v2
Reading and writting v2
ASU Online
01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one
ssuser656672
Chapter 2.4
Chapter 2.4
sotlsoc
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes
Intro C# Book
Java concurrency questions and answers
Java concurrency questions and answers
CodeOps Technologies LLP
14b exceptions
14b exceptions
Program in Interdisciplinary Computing
Learning Java 1 – Introduction
Learning Java 1 – Introduction
caswenson
J Unit
J Unit
guest333f37c3
Programming in Java: Organising Your Code
Programming in Java: Organising Your Code
Martin Chapman
Introduction to java programming part 2
Introduction to java programming part 2
university of education,Lahore
Java programs
Java programs
Dr.M.Karthika parthasarathy
Java For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
Interface and abstraction
Interface and abstraction
Raghav Chhabra
Exploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systems
InfinIT - Innovationsnetværket for it
Java For Automation
Java For Automation
Abhijeet Dubey
Thread
Thread
phanleson
00_Introduction to Java.ppt
00_Introduction to Java.ppt
HongAnhNguyn285885
Twins: OOP and FP
Twins: OOP and FP
RichardWarburton
Semelhante a 02 prepcode
(20)
02 - Prepcode
02 - Prepcode
Java
Java
Reading and writting v2
Reading and writting v2
01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one
Chapter 2.4
Chapter 2.4
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes
Java concurrency questions and answers
Java concurrency questions and answers
14b exceptions
14b exceptions
Learning Java 1 – Introduction
Learning Java 1 – Introduction
J Unit
J Unit
Programming in Java: Organising Your Code
Programming in Java: Organising Your Code
Introduction to java programming part 2
Introduction to java programming part 2
Java programs
Java programs
Java For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Interface and abstraction
Interface and abstraction
Exploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systems
Java For Automation
Java For Automation
Thread
Thread
00_Introduction to Java.ppt
00_Introduction to Java.ppt
Twins: OOP and FP
Twins: OOP and FP
Mais de Program in Interdisciplinary Computing
Phpmysqlcoding
Phpmysqlcoding
Program in Interdisciplinary Computing
Database basics
Database basics
Program in Interdisciplinary Computing
CGS2835 HTML5
CGS2835 HTML5
Program in Interdisciplinary Computing
Mysocial databasequeries
Mysocial databasequeries
Program in Interdisciplinary Computing
Mysocial databasequeries
Mysocial databasequeries
Program in Interdisciplinary Computing
CGS2835 HTML5
CGS2835 HTML5
Program in Interdisciplinary Computing
01 intro tousingjava
01 intro tousingjava
Program in Interdisciplinary Computing
Web architecture v3
Web architecture v3
Program in Interdisciplinary Computing
Xhtml
Xhtml
Program in Interdisciplinary Computing
Webdev
Webdev
Program in Interdisciplinary Computing
Sdlc
Sdlc
Program in Interdisciplinary Computing
Mysocial
Mysocial
Program in Interdisciplinary Computing
Javascript
Javascript
Program in Interdisciplinary Computing
Javascript
Javascript
Program in Interdisciplinary Computing
Frameworks
Frameworks
Program in Interdisciplinary Computing
Drupal
Drupal
Program in Interdisciplinary Computing
Database
Database
Program in Interdisciplinary Computing
12 abstract classes
12 abstract classes
Program in Interdisciplinary Computing
11 polymorphism
11 polymorphism
Program in Interdisciplinary Computing
15b more gui
15b more gui
Program in Interdisciplinary Computing
Mais de Program in Interdisciplinary Computing
(20)
Phpmysqlcoding
Phpmysqlcoding
Database basics
Database basics
CGS2835 HTML5
CGS2835 HTML5
Mysocial databasequeries
Mysocial databasequeries
Mysocial databasequeries
Mysocial databasequeries
CGS2835 HTML5
CGS2835 HTML5
01 intro tousingjava
01 intro tousingjava
Web architecture v3
Web architecture v3
Xhtml
Xhtml
Webdev
Webdev
Sdlc
Sdlc
Mysocial
Mysocial
Javascript
Javascript
Javascript
Javascript
Frameworks
Frameworks
Drupal
Drupal
Database
Database
12 abstract classes
12 abstract classes
11 polymorphism
11 polymorphism
15b more gui
15b more gui
02 prepcode
1.
Anatomy of a
Class LIS4930 © PIC The name of the method The name of this class This is a class The return type. Void means there is nothing returned Opening of curly brace of the class Arguments to the method. This method must be given an array of String, and the array will be called ‘args’ Public so everyone can access it public class MyFirstApp { public static void main (String [ ] args ) { System.out.println (“I Rule!”) ; } } Opening brace of the method We’ll cover this later. Every statement MUST end in a semicolon! Closing brace of the MyFirstApp class A string you want to print This says print to standard output (defaults to command-line) Closing brace of the method DONT WORRY ABOUT MEMORIZING ANYTHING RIGHT NOW… THIS IS JUST SOMETHING TO GET THAT SWEET JAVA AMORA IN THE AIR
2.
The main thing
is to keep the main thing the main thing. ~ Stephen Covey When the JVM (Java Virtual Machine) starts running, it looks for the class you give it at the command line. Then it starts looking for a specifically-written method that looks exactly like: public static void main (String [ ] args) { //your code goes here } What’s this? This is called the “main” method, and the JVM runs everything between the curly braces { } of this main method. Every Java application has to have as least one class, and at least one main method. (NOT one main per class; just one main per application).The main( ) method tells the computer where to start, and you only need one starting place. LIS4930 © PIC
3.
Writing a Class
with a Main LIS4930 © PIC In Java everything goes into a class. You’ll type your source code file (with a .java extension), then compile it into a new class file (with a .class extension). When you run your program, you’re really running a class. 1 MyFirstApp.java public class MyFirstApp { public static void main (String [ ] args) { System.out.println(“I Rule!”); System.out.println(“The World”); } } Save 2 Compile javac MyFirstApp.java 3 java MyFirstApp Run
4.
What can the
main method do? LIS4930 © PIC Your code can tell the JVM to: do something again and again do something under this condition do something while (x >12) { x = x + 1; } for (intx = 0; x < 10; x = x + 1) { System.out.print(“x is now “+ x); } if (x == 10) { System.out.print(“x must be 10”); } else { System.out.print(“x isn’t 10”); } if ((x < 3) & (name.equals(“Kyle”))) { System.out.println(“Gently”); } System.out.print(“This line runs no matter what”); intx = 3; String name = “Kyle”; x = x +17; System.out.print(“x is “ + x); double d = Math.random(); //this is a comment 1 2 3 Statements: declarations, assignments, method calls, etc. Loops: for and while Branching: if…else tests
5.
Syntax Fun Each
statement must end in a semicolon: x = x + 1; A single-line comment begins with two forward slashes: x = 22; //this is a comment Most white space doesn’t matter: x = 3 ; Variables are declared with a name and a type(you’ll learn about all the Java types in chapter 3). intweight; //type: int, name: weight Classes and methods must be defined within a pair of curly braces. public void go( ) { //amazing code here } LIS4930 © PIC
6.
Looping, Looping, Looping
LIS4930 © PIC Java offers three types of looping structures: while, do-while, and for. We’ll discuss the others later, but for now we will only discuss while. The while loop keeps looping as long as some condition is true, this is called the conditional test. What is done on each loop is found inside the loop block, which is located after the conditional test within The key to a loop is a conditional test. In Java, a conditional test is an expression that results in a boolean value – in other words, something that is either true or false. curly braces. while (moreBalls == true) { keepJuggling( ); }
7.
Simple Boolean Tests
LIS4930 © PIC You can do a simple boolean test by checking the value of a variable, using a comparison operator including: < (less than) > (greater than) == (equality) intx = 4; //assign 4 to x while (x > 3) { // loop code will run because // xis greater than 3 x = x – 1; } intz = 27; while (z == 17) { // loop code will not run because // z is not equal to 17 } Yes that is TWO equal signs. Notice the difference: the assignment operator is = and the equality operator is ==. Lots of programmers accidently type = when they want ==, but not you
8.
Example of a
while loop LIS4930 © PIC public class Loopy { public static void main (String[ ] args) { intx = 1; System.out.println(“Before the Loop.”); while (x < 4) { System.out.println(“In the loop”); System.out.println(“Value of x is “ + x); x = x + 1; } System.out.println(“This is after the loop”); } } Let’s see how it works
9.
Conditional Branching LIS4930
© PIC public class IfTest { public static void main (String[ ] args) { intx = 3; if (x == 3) { System.out.print(“x must be 3”); } System.out.print(“This runs no matter what”); } } public class IfTest { public static void main (String[ ] args) { intx = 3; if (x == 3) { System.out.println(“x must be 3”); } System.out.println(“This runs no matter what”); } } What’s different?
10.
Conditional Branching LIS4930
© PIC public class IfTest { public static void main (String[ ] args) { intx = 3; if (x == 3) { System.out.println(“x must be 3”); } else { System.out.println(“x is NOT 3”); } System.out.println(“This runs no matter what”); } } What about this one? What is this?
11.
Coding a Serious
Business Application LIS4930 © PIC With the tools we have covered up to this point you have just about enough skills to code your first program. Who knows the lyrics to “99 Bottles of Beer on the Wall”? So how do we do it, what do we need?
12.
Be Prepared ~
Robert Baden-Powell Before you start programming begin with creating prepcode. Use keywords like: LIS4930 © PIC A form or pseudocode, to help you focus on the logic without stressing about syntax.
13.
What would the
prepcode look like for “99 bottles of beer on the wall”? LIS4930 © PIC Prepcode for “99 bottles of beer on the wall”. DECLARE counter SET to 99 REPEAT until counter EQUALS 1 PRINT counter + “bottles of beer on the wall,” PRINT counter + “bottles of beer.” PRINT “Take one down and pass it around,” DECREMENT counter IF counter EQUALS 1 PRINT counter + “bottle of beer on the wall.” END IF ELSE PRINT counter + “bottles of beer on the wall.” END ELSE END REPEAT PRINT counter + “bottle of beer on the wall,” PRINT counter + “bottle of beer.” PRINT “Take one down and pass it around,” PRINT “no more bottles of beer on the wall.”
14.
Try it Yourselves!
Work with the person sitting next to you (groups of two ONLY). Write prepcode, as demonstrated in class, for creating a Java program to print out the lyrics to a popular camp/bus song. Use a word processor to type up your final draft and save it for later. Raise your hand for the teacher or TA to inspect your group’s final draft and give suggestions on how it might be improved. Have the TA signoff the attendance sheet to mark you were present in class and did the work. LIS4930 © PIC
15.
Homework! Practice writing
prepcode. Install Eclipse. Experiment with writing your first Java program. Quizzes start next week… (I won’t remind you every again – quizzes are listed on the Course Content page) LIS4930 © PIC
Baixar agora