Chapter 2: Java Fundamentals

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
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)
Chapter 2: Java Fundamentals Operators. Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR Page 2 Content Group of Operators Arithmetic Operators Assignment.
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.
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,
Chapter 2: Java Fundamentals Java Program Structure.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
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.
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.
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.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
DOCUMENTATION SECTION GLOBAL DECLARATION SECTION
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.
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.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
Learning Plan 6 Java Programming Intro to Object Oriented Programming.
Comp1004: Introduction III Java. Content How Java Works: The JVM Writing a Class in Java – Class – Member Variables – Method – Statement Magic incantations.
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.
Java Programming in Unix
CSC111 Quick Revision.
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE
Object-Oriented Programming Using Java
Chapter 3 GC 101 Java Fundamentals.
Compiling and Running a Java Program
Introduction to.
Chapter 2 part #1 C++ Program Structure
Introduction to C Language
Java Intro III.1 (Fr Feb 23).
PROGRAM STRUCTURE CSC 111.
An Introduction to Java – Part I, language basics
Hands-on Introduction to JAVA
Chapter 3 Classes and Objects
Fundamentals 2.
Java Intro.
Chapter 2: Java Fundamentals
Chapter 2: Java Fundamentals
Chap 4. Programming Fundamentals
F II 2. Simple Java Programs Objectives
Computer Programming-1 CSC 111
Methods/Functions.
Chapter 2 part #1 C++ Program Structure
Presentation transcript:

Chapter 2: Java Fundamentals Java Program Structure

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

Java Program Structure // 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 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP

Dr. S. GANNOUNI & Dr. A. TOUIR Salam Program // 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 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP

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 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP

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. Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP