Tonga Institute of Higher Education

Slides:



Advertisements
Similar presentations
Classes  All code in a Java program is part of a class  A class has two purposes  Provide functions to do work for the programmer  Represent data.
Advertisements

Begin Java Pepper. Objectives What is a program? Learn the basics of your programming tool: BlueJ Write a first Java program and see it run Make some.
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.
Your First Java Program: HelloWorld.java
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.
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,
 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.
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Computer Science A 1: 3/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Programming Part 1 Armond R. Smith Zhenying Wu. Overview of this Class ● Transition from FTC -> FRC ● Using Your Resources ● Java Keywords o Data Types.
Unit 2: Java Introduction to Programming 2.1 Initial Example.
“Introduction to Programming With Java”
Hello AP Computer Science!. What are some of the things that you have used computers for?
2.2 Information on Program Appearance and Printing.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
C# B 1 CSC 298 Writing a C# application. C# B 2 A first C# application // Display Hello, world on the screen public class HelloWorld { public static void.
Welcome to the Lecture Series on “Introduction to Programming With Java”
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
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.
Output in Java Hello World!. Structure of a Java Program  All Java files in ICS3U1 have the following structure: class HelloWorld { }  Notice the open.
Pre-Sessional Java Programming Lecture 1a Reyer Zwiggelaar
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
Code Conventions Tonga Institute of Higher Education.
Week 1 basic Python programs, defining functions Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Working With Objects Tonga Institute of Higher Education.
Indentation & Readability. What does this program do? public class Hello { public static void main ( String[] args ) { //display initial message System.out.println(
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
Lab 01-2 Objectives:  Writing a Java program.  How to send output to the command line console.  Learn about escape sequences.  Learn how to compile,
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
A High Flying Overview CS139 – Fall 2006 How far we have come.
© 2007 Lawrenceville Press Slide 1 Chapter 3 Classes and Objects 1. How is a class different from an object?
Java Programming Daily review / 1 PT. each. September 28/29: Lesson 1 - a 1. Create the “skeleton” of a program Public class Tester { Public static void.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
CS 177 Recitation Week 1 – Intro to Java. Questions?
Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
Java Methods and Applications CSIS 3701: Advanced Object Oriented Programming.
Introduction to Object Oriented
Introduction to programming in java
Computer Programming Your First Java Program: HelloWorld.java.
Introduction to Java Import Scanner class to use in our program
Object-Oriented programming for Beginners LEAPS Computing 2015
The eclipse IDE IDE = “Integrated Development Environment”
John Woodward A Simple Program – Hello world
Exercise Java programming
Introduction to.
USING ECLIPSE TO CREATE HELLO WORLD
basic Python programs, defining functions
Intro to Java.
CS139 – Fall 2010 How far we have come
Statements, Comments & Simple Arithmetic
Writing Methods.
Java: Getting Started Basic Class Structure
Tonga Institute of Higher Education
Java Intro.
CS110D Programming Language I
class PrintOnetoTen { public static void main(String args[]) {
Tonga Institute of Higher Education
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Tonga Institute of Higher Education
Methods/Functions.
© A+ Computer Science - Basic Java © A+ Computer Science -
Presentation transcript:

Tonga Institute of Higher Education Java Basics Tonga Institute of Higher Education

How Object Oriented Programs Work The building block of an object-oriented language is an object. Object - A self-contained entity that contains data and procedures to manipulate the data. An object is like a tool that we can use to do things.

Classes /* This program displays “Hello World!" to the standard output. */ class HelloWorld { public static void main(String[] args) { //Displays a message System.out.println(“Hello World!"); } Class - The blue print or design for creating an object. Each program must have a class Each class has a name Class names should be nouns One word The first letter is capitalized. The first letter of each internal word is capitalized. Keep your class names simple and descriptive. Example: Customer SalesOrder You need an open bracket and a close bracket after the name of the class. The contents of the class is between the brackets Everything inside a class is indented.

Demonstration Create a class

Methods /** This program displays “Hello World!" to the standard output. */ class HelloWorld { public static void main(String[] args) { //Displays a message System.out.println(“Hello World!"); } Methods - Pieces of code that perform a single function Each method has a name Method names should be verbs One word The first letter is lower case. The first letter of each internal word is capitalized. Keep your method names simple and descriptive. Example: runFast getBackground showWelcomeMessage You need an open bracket and a close bracket after the name of the method. The contents of the method is between the brackets Everything inside a method is indented.

main() Method Each Java program must have a method called main(). /** This program displays “Hello World!" to the standard output. */ class HelloWorld { public static void main(String[] args) { //Displays a message System.out.println(“Hello World!"); } Each Java program must have a method called main(). The work of the program is started in the main method when the class is run from the command line prompt.

Creating methods Creating main methods Demonstration Creating methods Creating main methods

Details Java requires a lot of attention to detail! All Java statements must end with a semi-colon. Line breaks are ignored. Indentations are ignored. Even spaces are ignored except in quoted Strings. Use indentations and spaces to improve readability Case is important. Always check capitalization! Good System.out.println(“I love Java”); Bad system.out.Println(“I love Java”);