Reference Learning Java DDC publishing Herst, Yamauchi, Adler COP 3331 Object Oriented Analysis and Design Java Part I.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Introduction to Programming G51PRG University of Nottingham Revision 1
Today’s lecture Review of Chapter 1 Go over homework exercises for chapter 1.
Air Force Institute of Technology Electrical and Computer Engineering
1 pritisajja.info Unlocking the World of Java Programming….. Priti Srinivas Sajja February, 2014 Visit pritisajja.info for detail Future Technology for.
Chapter 3: Beginning Problem Solving Concepts for the Computer Programming Computer Programming Skills /1436 Department of Computer Science.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
Shlomo Hershkop1 Introduction to java Class 1 Fall 2003 Shlomo Hershkop.
Structure of a C program
CMT Programming Software Applications
Logical Operators Java provides two binary logical operators (&& and ||) that are used to combine boolean expressions. Java also provides one unary (!)
Java Syntax Primitive data types Operators Control statements.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Chapter 2 - Java Programming Fundamentals1 Chapter 2 Java Programming Fundamentals.
Programming Part 1 Armond R. Smith Zhenying Wu. Overview of this Class ● Transition from FTC -> FRC ● Using Your Resources ● Java Keywords o Data Types.
Java Overview CS2336: Computer Science II1. First Program public class HelloWorld { public static void main(String args[]) { System.out.println("Hello.
Introduction to C Language
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Chapter 2: Introducing Data Types and Operators.  Know Java’s primitive types  Use literals  Initialize variables  Know the scope rules of variables.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Variables 1.
DAT602 Database Application Development Lecture 5 JAVA Review.
INTRODUCTION TO JAVA CHAPTER 1 1. WHAT IS JAVA ? Java is a programming language and computing platform first released by Sun Microsystems in The.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
JAVA 0. HAFTA Algorithms FOURTH EDITION Robert Sedgewick and Kevin Wayne Princeton University.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
1 Programming Java Java Basics. 2 Java Program Java Application Program Application Program written in general programming language Applet Program running.
Primitive data Week 3. Lecture outcomes Primitive data – integer – double – string – char – Float – Long – boolean Declaration Initialisation Assignments.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
Basic Java Syntax COMP 401, Spring 2014 Lecture 2 1/14/2014.
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
By Mr. Muhammad Pervez Akhtar
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Java Part I By Wen Fei, HAO. Program Structure public class ClassName { public static void main(String[] args) { program statements } user defined methods.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Object Oriented Programming Lecture 2: BallWorld.
Java Programming Language Lecture27- An Introduction.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
Information and Computer Sciences University of Hawaii, Manoa
The Machine Model Memory
Introduction to C Programming
2.0 FUNDAMENTALS OF JAVA PROGRAMMING LANGUAGE
Yanal Alahmad Java Workshop Yanal Alahmad
C Basics.
Chapter 3: Understanding C# Language Fundamentals
Introduction to Programming in Java
Statements, Comments & Simple Arithmetic
CET 3640 – Lecture 2 Java Syntax Chapters 2, 4, 5
An Introduction to Java – Part I, language basics
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
C Programming Getting started Variables Basic C operators Conditionals
Java Programming Review 1
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
In this class, we will cover:
Introduction to java Part I By Shenglan Zhang.
Presentation transcript:

Reference Learning Java DDC publishing Herst, Yamauchi, Adler COP 3331 Object Oriented Analysis and Design Java Part I

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I // First Java Program // HelloWorld.java Public class HelloWorld { public static void main (String args[]) { System.out.println(“Hello World!”); }

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I The following compile sequence occurs in Unix on Diablo. HelloWorld.java HelloWorld Hello World!

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I FileDefinitionFunction javac.exeThe Java compiler Converts Java source code into executable byte-code java.exeThe Java enterpreter Runs the java program appletview.exeThe applet viewLocally runs a java applet from within an HTML file. jdb.exeThe Java debugger Used to debug your Java applications and applets javah.exeThe Java C header and stub file generator Creates C header files and C stub files from a java class, allowing your java and C code to interact. javap.exeThe Java class file disassembler Converts a compiled class back into source code. javadoc.exeThe Java API documentation generator Generates HTML documentation from Java Source Code Primary Java Program Files

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I General Java points to remember: –Java is case sensitive. –Use ; (semicolon) to terminate lines of code. –Use { } (curly braces) to indicate blocks of code for classes, methods, if statements, and loops. –Use spaces for indentation to make your code more readable.

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I Commen t TypeFunction //C++Everything after the // and until the end of the line is treated as a comment. /* */CEverything between the /* and */ is treated as a comment even if it crosses a line boundary. /** */HypertextSame as the C style comments except that these comments are read by Java’s documentation generator, which can generated HTML code from your comments. You can include HTML code in these comments.

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I Memory variables: Storage space declared inside the computer on memory is allocated through memory variables and constants. Java is strongly typed which means that memory variables can only hold their declared type of data. There are two types of data catetories: –Simple types. –Object types.

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I TypeSize byte8 bits char16 bits (unsigned) short16 bits int32 bits long64 bits float32 bits double64 bits boolean1 bit Simple data types are not based on any other type. These sizes do not vary from machine to machine. All numeric types are signed except character. Java is case sensitive. Names of simple data types Are in lower case as shown. Simple Types

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I Declaring Variables Format: data_type variable_name; data_type variable_name =value; Example: int j; // integer char opt; // character short I; // short integer long L; // long integer float F; // real number double D; // 64 bit real number boolean ok; // True/False int I,j,k,l; char Men = “A”;

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I OperatorMeaningExample -Unary negationx = -y; +Additionx= y + z + x; -Subtractionx=y-z-x; *Multiplicationz = x * y; /Divisionz = x / y; %Modulusn = x % 3; ++Increment by 1x++; ++y; --Decrement by 1x--; Note: There is not operator for exponent. You must use the Math.pow() function for this task. Arithmetic Operators

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I OperatorMeaningExample !=Not Equalif(x != 100) y=Z; <Less thenif(x < 100) y=Z; <=Less then or equal toif(x <= 100) y=Z; >Greater thenif(x > 100) y=Z; >=Greater then or equal to if( <= 100) y=Z; !NotAnswer = !Answer; &Andif( x=100 & y==0 ) y=Z; |Orif( x=100 | y==0 ) y=Z; ^Exclusive Orif( x=100 ^ y==0 ) y=Z; &&Short circuit Andif (x <3 && y==0) z=7; ||Short circuit ORif (x <3 || y==0) z=7; Comparison and logical Operators On the short circuit operators, the next comparison is not accomplished if it does not affect the outcome.

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I OperatorMeaningExample ~Bitwise compliment x = ~x; //flips each bit. &Bitwise Andif(y&2 == 2) |Bitwise Orx = 3|5; // result 7 ^Bitwise Xorx=3^5; // Result 6 <<Left Shiftx = 1<<2; // Result 4 >>Sign propagating right shift I = 8>> 2; // Result 2 >>>Zero-fill right shift I = 8 >>>2;// result 2

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I Conditional Execution if(condition) statement; if(condition) { statement1; statement 2; statemetn 3; etc; }

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I if(condition) { statement1; statement2; } else { statement1; statement2; }

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I Switch Statements switch (expression) { case value1: statements; case value2: statements;... default: statements; } switch (input_char) { case ‘y’: System.out.print(“Entered y”); case ‘n’: System.out.print(“Entered n”); default: System.out.print(“Don’t know”); }

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I Loops for (initialize; condition; increment) { statements; } example: for (i=1; i<100; i++) { System.out.print(i); }

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I while (condition) { statements; } while (J < 100) { { J = J + 1; System.out.print(J); }

Reference Learning Java DDC publishing Herst, Yamauchi, Adler Java Part I Command Line Arguments: In all Java applications, the main() function accepts an argument, an array of strings called args[]; This array contains command line arguments. For instance, if you entered the following on the HelloWorld program: java HelloWorld Arg1 Arg2 “Hello Again” The args.length would equal three (3). and the contents would be: args[0] -> “Arg1” args[1] -> “Arg2” args[2] -> “Hello Again”