1 / 9

Java Coding Introduction

Java Coding Introduction. Scott McElfresh SAMS 2004. Software Creation Cycle. Edit Compile Run Test Debug. Software Creation Cycle. Edit word processor, text editor, Project Builder Compile javac programname.java sh compile.sh Run java programname sh run.sh Test

asay
Download Presentation

Java Coding Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Coding Introduction Scott McElfresh SAMS 2004

  2. Software Creation Cycle • Edit • Compile • Run • Test • Debug

  3. Software Creation Cycle • Edit • word processor, text editor, Project Builder • Compile • javac programname.java • sh compile.sh • Run • java programname • sh run.sh • Test • make sure everything works as desired • Debug

  4. Objects, Classes, and Behavior • In Java programming, items of interest are called objects • Objects that share common behavior are grouped into classes. • Once a class is defined in Java, objects of that class can be created. These are called instances. • Java has some classes pre-defined for us. • In this course, we will also use classes created by other programmers.

  5. Messages • Requesting that an object do something (execute one of its behaviors) is called a sending a message, or calling a method. • To send a message, we must specify the object and the desired behavior. EG: • bob.goToStore(); • jane.goToStore(butter); // butter is a “parameter” • bill.howOldAreYou()

  6. Variables • Variables in Java refer to specific objects. • Java needs a way to refer to the object, so requires an identifier. • Identifiers can have letters and numbers, and must start with a letter.

  7. Conditional code • Some actions are only desirable under certain conditions. if (out of butter) mary.goToStore(butter) • If statements allow us to check the state of the world and make a decision about what to do. if (mary.outOfButter()) mary.goToStore(butter); else mary.goToFriendsHouse();

  8. Comments andInternal Documentation • Comments are code for HUMANS to read, not the computer. • /* …. */ indicates comments between. • // indicates comments on the rest of the line • Project builder typically makes these green.

  9. Items on screen in this project • For each item on your screen, you need to do 3 or 4 things: • Choose a name for the item. Declare this to Java. • Create the item and fill in details (eg. location size) • Add it to your display and tell Java how this item relates to other items on screen. • Tell Java what to do when this item is in focus and phone keys are pressed.

More Related