1 / 13

beginning Programming

beginning Programming. What is programming?. Literally – giving instructions to a computer so that it does what you want Practically – using a programming language (such as Java) to solve a problem Ex: Controlling a robot autonomously, mathematical computations, vision processing.

kayo
Download Presentation

beginning Programming

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. beginning Programming

  2. What is programming? • Literally – giving instructions to a computer so that it does what you want • Practically – using a programming language (such as Java) to solve a problem • Ex: Controlling a robot autonomously, mathematical computations, vision processing

  3. What is java? • Cross-platform write-once run anywhere high level object-oriented programming language • The Java Virtual Machine • Software that runs on most operating systems • Runs your java code • Handles all OS specific programming problems • Write a program one time and run it on every major OS

  4. Object oriented Java is based on Objects An Object is an instance of any class, e.g. a String variable Objects provide different functionalities depending on what it’s class was designed to do Makes programming easier because Objects do most of the work

  5. The Structure of a Basic Program public static void main(String[] args){…} Primitive types (variables) boolean (true or false) byte (0-255) char (a single letter/character) short (small integer) int (an integer) float (decimal number) double (decimal with double precision of float) long (very large integer)

  6. Simple Objects An object is an instance of any class (e.g. an instance of the String class) String Not a primitive type PrintStream (e.g. System.out) Allows you to output data

  7. The “Hello World Program” • The most basic program in any language – just prints out “Hello World” • In Java

  8. Conditionals • “Modifies” your program at runtime • Changes what/when the program does something based on a test • Ex: • If a is greater than b, the program does one thing, and does another if a is not greater than • Else – the code inside the else block executes if none of the if statements are true

  9. Iteration • Used when you want to do something multiple times or while a condition is true • For loop • While loop • Do-while loop

  10. Methods • Public void name(){…} • Most basic definition: a block of code that does something useful • Use methods to simplify code and make programming easier • Ex: arm.setAngle(90) is much easier than directly controlling the motors and stopping it at 90 degrees

  11. Method Arguments • Argument – any data that you pass to a method • Ex: • Where a and b are the numbers that you want to add • Arguments give data to a method so that it can do what it was designed to do

  12. Method Modifiers • Public/Private – controls who can access this method • Private - only accessible within the defining class • Public - accessible by any class or object • Static – no instance of object required to run the method

  13. Returning Data From a Method • Void – doesn’t return anything • Ex: • Object – returns an Object of the specified class • Ex: • Return data using the return command • Ex:

More Related