Chapter 2: Java Fundamentals Java Program Structure.

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

IT151: Introduction to Programming
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Your First Java Program: HelloWorld.java
Chapter 1: Introduction
Repetition Chapter 4: Control structures. Introduction to OOPDr. S. GANNOUNI & Dr. A. TOUIRPage 2 Loop Statements After reading and studying this Section,
CPSC150 Fall 2008 Dr. L. Lambert. CPSC150 Overview Syllabus Use Textbook, ask questions, extra thorough, I will post sections covered All information.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
1 Introduction to Java and Applet. 2 Download Java Compiler (1)
Class attributes Chapter 3: Introduction to Classes and Objects.
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,
Chapter 2: Java Fundamentals Input and Output statements.
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.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –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,
Objects and Instance attributes and variables Chapter 3: Introduction to Classes and Objects.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
Exercises A-Declare a variable of double type with initial value=0.0; B- Declare a constant of String type with initial value=“Good” C- Declare a variable.
CS107 Introduction to Computer Science Java Basics.
INTRODUCTION TO JAVA CHAPTER 1 1. WHAT IS JAVA ? Java is a programming language and computing platform first released by Sun Microsystems in The.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Java Fundamentals 3 Input and Output statements. Standard Output Window Using System.out, we can output multiple lines of text to the standard output.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE 1 st semester H 1 King Saud University College of Applied studies and Community Service Csc 1101 By:
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
Using the while-statement to process data files. General procedure to access a data file General procedure in computer programming to read data from a.
CSI 3125, Preliminaries, page 1 Compiling the Program.
The assignment expressions. The assignment operator in an assignment statement We have seen the assignment statement: Effect: var = expr; Stores the value.
CSc 201 Introduction to Java George Wells Room 007, Hamilton Building
By Mr. Muhammad Pervez Akhtar
Java FilesOops - Mistake Java lingoSyntax
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.
 CSC111 Quick Revision. Problem Write a java code that read a string, then show a list of options to the user to select from them, where:  L to print.
Classes and Objects. Object Software objects are modeled after real-world objects in that they, too, have state and behavior. A software object maintains.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
Classes and Objects. Object vs. Class Introduction to OOPDr. S. GANNOUNI & Dr. A. TOUIRPage 2  A class could be considered as a set of objects having.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
Comp1004: Introduction III Java. Content How Java Works: The JVM Writing a Class in Java – Class – Member Variables – Method – Statement Magic incantations.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.
Lecture 3: Scaffolding and Output Announcements & Review Announcements Discussion Sections: PAI 5.70 until further notice Pair in same discussion
Introduction to programming in java
Computer Programming Your First Java Program: HelloWorld.java.
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE
Chapter 3 GC 101 Java Fundamentals.
Compiling and Running a Java Program
Introduction to.
Chapter 2 part #1 C++ Program Structure
An Introduction to Java – Part I, language basics
Hands-on Introduction to JAVA
Java Intro.
Chapter 2: Java Fundamentals
F II 2. Simple Java Programs Objectives
Computer Programming-1 CSC 111
Presentation transcript:

Chapter 2: Java Fundamentals Java Program Structure

Introduction to OOPDr. S. GANNOUNI & Dr. A. TOUIRPage 2 Content Java Program Structure Salam Program Saving, Compiling and Running Java Programs Comments

Introduction to OOPDr. S. GANNOUNI & Dr. A. TOUIRPage 3 // import Section – import used java libraries public class MyProgramName { // main method public static void main( String args[] ){ // Declaration section – Declare needed variables // Input section – Enter required data // Processing section – Processing Statements // Output section – Display expected results } // end main } // end class Java Program Structure

Introduction to OOPDr. S. GANNOUNI & Dr. A. TOUIRPage 4 // import section: Empty public class MySalamProgram { // main method public static void main( String args[] ){ // Declaration section: Empty // Input section: Empty // Processing section: Empty // Output section System.out.println(“… Assalamo Alaikom …”); } // end main } // end class Salam Program

Introduction to OOPDr. S. GANNOUNI & Dr. A. TOUIRPage 5 Saving, Compiling and Running Java Programs Saving a Java program. –A file having a name same as the class name should be used to save the program. The extension of this file is ”.java”. –Salam program should be saved in a file called “MySalamProgram.java”. Compiling a Java program. –Call the Java compiler javac: –javac MySalamProgram.java –The Java compiler generates a file called ” MySalamProgram.class” (the bytecode). Running a Java program –Call the Java Virtual Machine java: –java MySalamProgram.class

Introduction to OOPDr. S. GANNOUNI & Dr. A. TOUIRPage 6 Comments in a Java Program Comments are used to describe what your code does and aid reading your code. The Java compiler ignores them. Comments are made using –//, which comments to the end of the line, –or /* */, everything inside of it is considered a comment (including multiple lines). The comment begins after the first /*. It ends just before the first */. Examples: /* This comment begins at this line. This line is included in this comment It ends at this line. */ // This comment starts here and ends at the end of this line.