1 / 13

CSE 1341 Honors

CSE 1341 Honors. Note Set 02 Professor Mark Fontenot Southern Methodist University. What is Java?. “High-Level Programming Language” Allows the programmer to write instructions in something similar to English (loosely speaking) Portable (sometimes)

kylan-vance
Download Presentation

CSE 1341 Honors

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. CSE 1341 Honors Note Set 02 Professor Mark Fontenot Southern Methodist University

  2. What is Java? • “High-Level Programming Language” • Allows the programmer to write instructions in something similar to English (loosely speaking) • Portable (sometimes) • Can take code and move from one machine type to another with little or no modification • Think: Linux to PC • Opposite of HL Language = Low Level Language • Commands are specific to the hardware/processor • Hard to read/Hard to write • The only thing a computer can really execute, though.

  3. Getting from HL to LL… • Compiling and Interpreting • Both are means for turning HL instructions into LL instructions • Compiler and Interpreter are pieces of software that translate HL code to LL code Source Code (What the human writes) Object Code (What the Computer understands) Compiler/Interpreter

  4. Java is (a little) special • Java uses both compiling and interpreting • Java compiler (command: javac) compiles Java source code to generic Byte Code • Java runtime/interpreter (command: java) translates byte code to machine code “on the fly” • New Acronym: JVM • Stands for Java Virtual Machine • Able to execute Java Byte Code Java Source Code Java Byte Code Running Program Java Compiler Interpreter

  5. What’s a program? • A sequence of instructions to solve a problem. • Usually have the following components: • Input • From the user, • From another program • From a sensor… • Processing • Does something useful with the data • Output • Displays something, sends commands to somewhere else (like a robot), etc…

  6. What’s a Program? • More Components of a Program • The ability to test conditions • if (x < 10) System.out.println(“X is too small”); • The ability to perform actions repeatedly • while (x < 20) {System.out.println(x);x++;} • That’s pretty much it….. All programs you use can be broken down to those 5 fundamental components

  7. When Things Go Wrong… • Things will go wrong • Syntax Error • There are rules about Java (we’ll be learning them) • You must follow the rules or the compiler complains • Run-Time Errors • Errors that only come to light while running a program • i.e. user enters something wrong and the program doesn’t know how to respond • Logic Errors/Semantic Error • Compile, run, no error message, but produces wrong output. • Example: Adding 2 numbers when you intended to multiply

  8. Debugging • You’re like a Java Detective • Look for clues about what the problem might be • Make inferences based on the way the program is improperly executing

  9. Breakout 1

  10. Looking at Java Class Name: Name of file has to be name of class with extension .java Comment – note to others that read this code about what it does public class Hello { //Say Hello To The World public static void main (String [] args) { System.out.println(“Hello World”); } } Method Output Statement/ Print Statement

  11. System.out.println() • println() is a function • It provides the functionality to print whatever is inside the () to the terminal (if possible). • Prints what is in the parentheses, then prints a new linecharacter so that the next thing that is printed will be on the next line. • Examples: • System.out.println(“Mark Fontenot”); • System.out.println(“3 + 4 = 7”);

  12. System.out.print() • print() is a function (as well)… • like println(), but doesn’t go down to the next line after it prints • System.out.print(“hello “); • System.out.println(“world”); • System.out.println(”hello world”);

  13. Breakout 2

More Related