Data Structures Lecture 1 Fang Yu Department of Management Information Systems National Chengchi University Fall 2011.

Slides:



Advertisements
Similar presentations
Java Basic Training HaiNH - FQA. Agenda Introduction to Java Java Programming Environment Language Fundamental Object Oriented Programming with Java.
Advertisements

Object Oriented Programming in Java George Mason University Fall 2011
Chapter 1: Introduction
Excerpts from Introduction to Java Programming, 4E Author: Y. Daniel Liang (Copyright by Prentice Hall)
Introduction to Java Programming, 4E
Introduction to Java Programming
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Unit2: Object-oriented programming Getting started with Java Jin Sa.
Computer Science A 1: 3/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
Writing algorithms using the for-statement. Programming example 1: find all divisors of a number We have seen a program using a while-statement to solve.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
Computer Programming Lab(4).
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 1
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
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.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
1 Introduction to Java Brief history of Java Sample Java Program Compiling & Executing Reading: => Section 1.1.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
1.8History of Java Java –Based on C and C++ –Originally developed in early 1991 for intelligent consumer electronic devices Market did not develop, project.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Object Oriented Programming Computer Engineering Department JAVA Programming Course Asst. Prof. Dr. Ahmet Sayar Kocaeli University - Fall 2014.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
Introduction to C++ Programming Language
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Programs.
POS 406 Java Technology And Beginning Java Code
Java Introduction 1. Introduction to Java Programming2 Computers and Computer Languages Computers are everywhere –how many computers do you own? Computers.
Introduction to Java Programming with Forte Y. Daniel Liang.
Clement Allen, PhD Florida A&M University SUMMER 2006.
Boolean expressions, part 2: Logical operators. Previously discussed Recall that there are 2 types of operators that return a boolean result (true or.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
A Look at Java. Categorize Java Which paradigm? Which paradigm? Scripting? Scripting? Declarative or procedural? Declarative or procedural? Which generation?
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
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.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 3.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
Introduction to array: why use arrays ?. Motivational example Problem: Write a program that reads in and stores away 5 double numbers After reading in.
Creating Web Services Presented by Ashraf Memon Presented by Ashraf Memon.
Boolean expressions, part 1: Compare operators. Compare operators Compare operators compare 2 numerical values and return a Boolean (logical) value A.
Simple algorithms on an array - compute sum and min.
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
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.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Introduction to JAVA Programming
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.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
CS-140 Dick Steflik Lecture 3. Java C++ Interpreted optimized for the internet Runs on virtual ized machine Derived from C++ Good object model Widely.
Lecture 2 D&D Chapter 2 & Intro to Eclipse IDE Date.
Compiling and Running a Java Program
Introduction to.
Internet and Java Foundations, Programming and Practice
CompSci 230 Software Construction
Comp Sci 200 Programming I Jim Williams, PhD.
Something about Java Introduction to Problem Solving and Programming 1.
Getting Started ARCS Lab..
An Introduction to Java – Part I, language basics
Introduction to Java Brief history of Java Sample Java Program
Building Java Programs
Computer Programming-1 CSC 111
Presentation transcript:

Data Structures Lecture 1 Fang Yu Department of Management Information Systems National Chengchi University Fall 2011

A brief review of Java programming

Popularity of Programing Languages

About Java Java is  the most popular language in the past years: o/tpci/index.html o/tpci/index.html  Simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, multi- threaded, dynamic, and more. Classes, Types, and Objects  An object is the basic unit in Java  A class defines the type of an object

Java Programming Basics  A class consists of  fields (to store data)  methods (to define operations that can act on data) public class Hello { public static int var ; public static void say (String s) { System.out.print(“Hello ”+s); } public static void main (String[] argv) { say(”World!"); } A field A method The main method (The entry point while executing the program) The class name (this code must save as Hello.java)

public class Hello { public static int var; public static void say(String s) { System.out.print(“Hello ”+s); } public static void main(String[] argv) { say(”World!"); } “public” indicates that anyone can run/extend/import this class “static” indicates the field/method belongs to the class, not objects “void” indicates that the method returns nothing Modifiers

How Java works  Execute your code on command line  “javac Hello.java” to generate Hello.class  “java Hello” to execute the bytecode Java source code Compile Java bytecode Java Virtual Machine result Hello.java Hello.class Interpret

Example: Operator  Operators are similar to C++  E.g., =, +, -, *, /, %  A simple example:  Sum 1 to 100 using a formula public class Example { public static void main(String[] argv) { int n = 100; System.out.println(" "+n+" = " + ( n * (n + 1) / 2)); } javac Example.java java Example = 5050

Example: Loop  Sum 1 to 100 using a method with for-loop public class Example { public static int sum(int n) { int total = 0; for (int i = 1; i <= n; i++) { total += i; } return total; } public static void main(String[] argv) { int n = 100; System.out.println(" "+n+" = " + sum(n)); } javac Example.java java Example = 5050

Use pre-defined class library  Use java.util.Scanner for getting inputs  The Scanner class reads the input stream and divides it into tokens by delimiters (whitespace)  The Scanner class includes the following methods: hasNext()Return true if there is another token next()Return the next token hasNext Type () Return true if there is another token that can be interpreted as the Type next Type () Return the next token that can be interpreted as the Type

Use pre-defined class library  Import the package import java.util.Scanner;  Construct a Scanner object: Scanner in = new Scanner(System.in);  Call its method: e.g., in.nextInt() or in.hasNext()

Example: Simple Input  Sum using java.util.Scanner class import java.util.Scanner; public class Example { public static int sum(int n) { int total = 0; for (int i = 1; i <= n; i++) { total += i; } return total; } public static void main(String[] argv) { Scanner in = new Scanner(System.in); System.out.print(“Enter n: ”); int n = in.nextInt(); System.out.println(" "+n+" = " + sum(n)); } javac Example.java java Example Enter n: = 5050

About Eclipse Eclipse is  an Integrated Development Environment (IDE) for Java and also many other languages  An open source platform (free!)  maintained by many software development leaders like IBM and Borland

Eclipse Extension Furthermore, Eclipse  provides a common environment that companies can modify and customize by creating plug-ins  These plug-ins can add functionality to Eclipse like modeling, UML, XML, metrics, reliability reports, and other information.  The Eclipse web site has a list of links to many popular plug-in repositories

A tutorial  A nice introduction to eclipse by L. Willaims et al. NCSU.  A nice java/eclipse tutorial on youtube:

Homework 1 (Due on 9/22)  BMI Calculator:  BMI = ( Weight in Kilograms / ( Height in Meters x Height in Meters ) )  Enter Height and Weight, return BMI and  “Fat” if BMI >= 30  “A bit out of shape” if 30 > BMI >= 24.5  “Healthy” if 24.5 > BMI >= 18  “Slim” if 18 > BMI  Use Eclipse to write/execute/debug your java code  Upload your code using WM3 ( no direct copy accepted)  TAs will show you “clear” hints to do so in tomorrow’s lab

Coming up…  We will discuss object oriented design and abstract data type next week  Read TB Chapter 1 and Chapter 2