CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.3 Write Your First Java Program Produced by Harvey.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 4 Writing Java Applications, Java Development Tools.
Advertisements

Introduction to programming in java. Input and output to screen with Java program Structure of Java programs Statements Conditional statements.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 2 Getting Started with Java Program development.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
Chapter 2: Your First Program! Hello World: Let’s Program  All programs must have the extension.java  Our first program will be named: HelloWorld.java.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Introduction To Computers and Programming Lecture 2: Your first program Professor: Evan Korth New York University.
1 Introduction to Java and Applet. 2 Download Java Compiler (1)
Excerpts from Introduction to Java Programming, 4E Author: Y. Daniel Liang (Copyright by Prentice Hall)
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 2 Getting Started with Java Structure of.
Introduction to Java Programming, 4E
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
Chapter 2: Java Fundamentals Java Program Structure.
public static void main (String[] args)
Unit 2: Java Introduction to Programming 2.1 Initial Example.
“Introduction to Programming With Java”
Introduction to Java Programming with JBuilder 4
S.W. Ma/CIM/LWL41211/2 Prog. IIA Page 1 HKIVE (Lee Wai Lee Campus) Department of CIM Course : Year 2 Module : Programming IIA Textbook : Introduction.
CompSci 42.1Intro to Java Anatomy of a Class & Terminology Running and Modifying a Program.
Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial.
Welcome to the Lecture Series on “Introduction to Programming With Java”
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.2 Getting the Tools and Setting Up the Development.
Chapter 2: Everything is an Object ● C++ has many non object oriented features inherited from C. It is a hybrid language meaning that it support different.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
POS 406 Java Technology And Beginning Java Code
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Introduction to Java Programming with Forte Y. Daniel Liang.
COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.1 Basics of Java Produced by Harvey Peters, 2008 Copyright.
Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Object Oriented Programming Lecture 3. Introduction  In discussing Java, some items need to be clarified  The Java programming language  The Java virtual.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 3- Introduction to Object Oriented Programming concepts Topic 3.6 Access Modifiers,
22-July-2002cse142-13B-Development © 2002 University of Washington1 Development Tools CSE 142, Summer 2002 Computer Programming 1
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1. An Introduction A Programming Language A Technology Java Development Kit Java API One Language: Three Editions Standard Edition Enterprise Edition.
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
CSc 201 Introduction to Java George Wells Room 007, Hamilton Building
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 4- Exception and Error Handling Topic 4.1 Errors and Exceptions Produced by Harvey.
introductory lecture on java programming
CPRG 215 Introduction to Object-Oriented Programming with Java Module 3- Introduction to Object Oriented Programming concepts Topic 3.4 Constructors, Overloading,
CPRG 215 Introduction to Object-Oriented Programming with Java Module 2- Using Java Built-in Classes Topic 2.6 Reading Input with java.io Produced by Harvey.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Using Java without BlueJ BlueJ projects A BlueJ project is stored in a directory on disk. A BlueJ package is stored in several different files.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
Introduction to Java Programming, 4E Y. Daniel Liang.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 3- Introduction to Object Oriented Programming concepts Topic 3.1 Fundamental Concepts.
Introduction to programming in java
Object-Oriented Programming Using Java
8/30/2018 CPRG 215 Introduction to Object-Oriented Programming with Java Module 5- The java.io Package Topic 5.1 Input and Output Streams, Readers.
Programming without BlueJ Week 12
Intro to Java.
Java Intro III.1 (Fr Feb 23).
Hands-on Introduction to JAVA
Java Intro.
Chapter 2: Java Fundamentals
Debugging Exercise 00 Try compiling the code samples.
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
Computer Programming-1 CSC 111
Presentation transcript:

CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.3 Write Your First Java Program Produced by Harvey Peters, 2008 Copyright SAIT

Please read the following sections in your textbook Core Java, Volume I–Fundamentals, Eighth Edition By Cay S. Horstmann & Gary Cornell Chapter 3 - Fundamental Programming Structures in Java A Simple Java Program Comments CPRG 215 Module 1.2- Getting the Tools and Setting Up the Development Machine Copyright SAIT

A simple Java program // // Sample public class HelloWorldApp { public static void main (String args[ ]) { System.out.println (“Hello World!”); } CPRG 215 Module 1.3- Write Your First Java Program Copyright SAIT Topic 1.3.1

A simple Java program CPRG 215 Module 1.3- Write Your First Java Program Copyright SAIT Topic // //Sample –Comments, not processed by Java public class HelloWorldApp –Defines this as a “class” –Every program in Java is a class –A class is like a template or blueprint that defines how an object should be built // // Sample public class HelloWorldApp { public static void main (String args[ ]) { System.out.println (“Hello World!”); }

A simple Java program CPRG 215 Module 1.3- Write Your First Java Program Copyright SAIT Topic { } –Code braces that group code statements together // // Sample public class HelloWorldApp { public static void main (String args[ ]) { System.out.println (“Hello World!”); }

A simple Java program CPRG 215 Module 1.3- Write Your First Java Program Copyright SAIT Topic public static void main(String args[ ]) –Definition for the main method –A class must have a main method in order to run –If you run a class that has no main method this message is displayed: Exception in thread "main" java.lang.NoSuchMethodError: main // // Sample public class HelloWorldApp { public static void main (String args[ ]) { System.out.println (“Hello World!”); }

A simple Java program public static void main(String args[ ]) public –access permission - most accessible level static –Able to run as soon as class loads into JVM –Normally methods don’t exist until we create an object from the class void –The method does not return any data (String args[]) –main receives a String array with command-line arguments is any are found CPRG 215 Module 1.3- Write Your First Java Program Copyright SAIT Topic 1.3.1

Compiling and running Compiling: –javac HelloWorldApp.java Running –java HelloWorldApp CPRG 215 Module 1.3- Write Your First Java Program Copyright SAIT Topic 1.3.2

Compiling and running Troubleshooting –bad command -- path –file not found -- typo? –Class not found -- forgot to compile? –Method not found -- typo? Case sensitivity –javac: invalid argument -- forgot.java CPRG 215 Module 1.3- Write Your First Java Program Copyright SAIT Topic 1.3.2

Documentation Comments // /**/ Javadoc /***/ CPRG 215 Module 1.3- Write Your First Java Program Copyright SAIT Topic 1.3.3

Documentation Comments // /**/ Javadoc /***/ CPRG 215 Module 1.3- Write Your First Java Program Copyright SAIT Topic 1.3.3