Lecture 1: Overview of Java

Similar documents
CSE 421 Course Overview and Introduction to Java

Introduction to Java

Index. Course Outline. Grading Policy. Lab Time Distribution. Important Instructions

Introduction to Java. Nihar Ranjan Roy.

Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of

Certified Core Java Developer VS-1036

CS 11 java track: lecture 1

CS11 Java. Fall Lecture 1

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

History Introduction to Java Characteristics of Java Data types

CHAPTER 1. Introduction to JAVA Programming

Lec 3. Compilers, Debugging, Hello World, and Variables

Crash Course in Java. Why Java? Java notes for C++ programmers. Network Programming in Java is very different than in C/C++

Advanced Object-Oriented Programming Introduction to OOP and Java


Lecture 2, September 4

Programming. Syntax and Semantics

Special Topics: Programming Languages

Introduction to Programming (Java) 2/12

Building Java Programs. Introduction to Programming and Simple Java Programs

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

II. Compiling and launching from Command-Line, IDE A simple JAVA program

Lecture 1: Introduction to Java

Introduction to Java

Fundamentals of Programming. By Budditha Hettige

COT 3530: Data Structures. Giri Narasimhan. ECS 389; Phone: x3748

Software Installation for CS121

Goals. Java - An Introduction. Java is Compiled and Interpreted. Architecture Neutral & Portable. Compiled Languages. Introduction to Java

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

Chapter 1 Introduction to Computers, Programs, and Java

Getting started with Java

CT 229. CT229 Lecture Notes. Labs. Tutorials. Lecture Notes. Programming II CT229. Objectives for CT229. IT Department NUI Galway

Java language. Part 1. Java fundamentals. Yevhen Berkunskyi, NUoS

An Introduction to Software Engineering. David Greenstein Monta Vista High School

S8352: Java From the Very Beginning Part I - Exercises

Pace University. Fundamental Concepts of CS121 1

Programming Language Concepts: Lecture 2

Compiling Techniques

CompSci 125 Lecture 02

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

Introduction to Programming Using Java (98-388)

2 rd class Department of Programming. OOP with Java Programming

IT151: Introduction to Programming (java)

Course information. Petr Hnětynka 2/2 Zk/Z

Introduction to Java Programming

Object Oriented Concepts and Programming (CSC244) By Dr. Tabbasum Naz

: Primitive data types Variables Operators if, if-else do-while, while, for. // // First Java Program. public class Hello {

Atelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Chapter 1 Introduction to Computers, Programs, and Java

CS 231 Data Structures and Algorithms, Fall 2016

Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer? A Bit of History

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform

Chapter 1 Introduction to Computers, Programs, and Java

Java Internals. Frank Yellin Tim Lindholm JavaSoft

Java Language. Programs. Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs.

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003

Answer1. Features of Java

CHAPTER 1 Introduction to Computers and Java

OOSD. Introduction to JAVA. Giuseppe Lipari Scuola Superiore Sant Anna Pisa. September 29, 2010

These two items are all you'll need to write your first application reading instructions in English.

Chapter 1 Introduction to Computers, Programs, and Java

Computer Components. Software{ User Programs. Operating System. Hardware

NetBeans IDE Java Quick Start Tutorial

Kickstart Intro to Java Part I

Course information. Petr Hnětynka 2/2 Zk/Z

Introduction to Java Programming CPIT 202. WEWwwbvxnvbxmnhsgfkdjfcn

Chapter 1 INTRODUCTION SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

This lecture will take you through simple and practical approach while learning Java Programming language.

엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University COPYRIGHTS 2017 EOM, HYEONSANG ALL RIGHTS RESERVED

PROGRAMMING FUNDAMENTALS

OOSD. Introduction to JAVA. Giuseppe Lipari Scuola Superiore Sant Anna Pisa. September 12, 2011

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

CS321 Languages and Compiler Design I. Winter 2012 Lecture 2

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

Chapter 1 Introduction to Computers, Programs, and Java

Java Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing

Tutorial 1 CSC 201. Java Programming Concepts عؾادئماظربجمةمبادؿكدامماجلاصا

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Chapter 1 Introduction to Java

G52PGP. Lecture oo3 Java (A real object oriented language)

STRUCTURING OF PROGRAM

C++ Spring Break Packet 11 The Java Programming Language

Chapter 1 Introduction to Computers, Programs, and Java

Lecture 4: Introduction to Java and your Development Environment

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Introduction to. Android Saturday. Yanqiao ZHU Google Camp School of Software Engineering, Tongji University. In courtesy of The Java Tutorials

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Lesson 01 Introduction

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Java Lecture Note. Prepared By:

CISC 370: Introduction to Java

INF160 IS Development Environments

Learning objectives. The Java Environment. Java timeline (cont d) Java timeline. Understand the basic features of Java

Programming Language Concepts: Lecture 2

From C++ to Java. Duke CPS

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Java is an objet-oriented programming language providing features that support

CS212:Data Structure

Lecture 8 Classes and Objects Part 2. MIT AITI June 15th, 2005

Transcription:

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 for easy Web/Internet applications Widespread acceptance 1

Java Features (1) Simple fixes some clumsy features of C++ no pointers automatic garbage collection rich pre-defined class library http://java.sun.com/j2se/1.4.2/docs/api/ Object oriented focus on the data (objects) and methods manipulating the data all functions are associated with objects almost all datatypes are objects (files, strings, etc.) potentially better code organization and reuse Java Features (2) Interpreted java compiler generate byte-codes, not native machine code the compiled byte-codes are platform-independent java bytecodes are translated on the fly to machine readable instructions in runtime (Java Virtual Machine) Portable same application runs on all platforms the sizes of the primitive data types are always the same the libraries define portable interfaces 2

Java Features (3) Reliable extensive compile-time and runtime error checking no pointers but real arrays. Memory corruptions or unauthorized memory accesses are impossible automatic garbage collection tracks objects usage over time Secure usage in networked environments requires more security memory allocation model is a major defense access restrictions are forced (private, public) Java Features (4) Multithreaded multiple concurrent threads of executions can run simultaneously utilizes a sophisticated set of synchronization primitives (based on monitors and condition variables paradigm) to achieve this Dynamic java is designed to adapt to evolving environment libraries can freely add new methods and instance variables without any effect on their clients interfaces promote flexibility and reusability in code by specifying a set of methods an object can perform, but leaves open how these methods should be implemented can check the class type in runtime 3

Java Disadvantages Slower than compiled language such as C an experiment in 1999 showed that Java was 3 or 4 times slower than C or C++ title of the article: Comparing Java vs. C/C++ Efficiency Issues to Interpersonal Issues (Lutz Prechelt) adequate for all but the most time-intensive programs Environment Setup Sun Solaris OS JDK 1.4 (latest: J2SE 5.0) You can use the lab at CL112. Please follow the steps: log into the Unix environment subscribe to JDK-CURRENT when you log in for the first time (% is a prompt sign) %> subscribe JDK-CURRENT and then log out by clicking on the EXIT button on the control panel 4

Install Java TM 2 Platform on your machine Can be installed on different platforms: Unix/Linux Windows Mac OS Follow the on-line instructions: http://java.sun.com/docs/books/tutorial/getstarted/cupojava/index.html Getting Started: (1) (1) Create the source file: open a text editor, type in the code which defines a class (HelloWorldApp) and then save it in a file (HelloWorldApp.java) file and class name are case sensitive and must be matched exactly (except the.java part) Example Code: HelloWorldApp.java /** * The HelloWorldApp class implements an application * that displays "Hello World!" to the standard output */ public class HelloWorldApp { public static void main(string[] args) { // Display "Hello World!" System.out.println("Hello World!"); } } Java is CASE SENSITIVE! 5

Getting Started: (2) (2) Compile the program: compile HelloWorldApp.java by using the following command: javac HelloWorldApp.java it generates a file named HelloWorldApp.class javac is not recognized as an internal or external command, operable program or hatch file. javac: Command not found if you see one of these errors, you have two choices: 1) specify the full path in which the javac program locates every time. For example: C:\j2sdk1.4.2_09\bin\javac HelloWorldApp.java 2) set the PATH environment variable Getting Started: (3) (3) Run the program: run the code through: java HelloWorldApp Note that the command is java, not javac, and you refer to HelloWorldApp, not HelloWorldApp.java or HelloWorldApp.class Exception in thread "main" java.lang.noclassdeffounderror: HelloWorldApp if you see this error, you may need to set the environment variable CLASSPATH. 6

Language basics (1) Data types 8 primitive types: boolean, byte, short, int, long, float, double, char Class types, either provided by Java, or made by programmers String, Integer, Array, Frame, Object, Person, Animal, Array types Variables datatype identifier [ = Expression]: Example variable declarations and initializations: int x; x=5; boolean b = true; Frame win = new Frame(); String x = how are you? ; int[] intarray; intarray = new int[2]; intarray[0] = 12; intarray[1] = 6; Person parray = new Person[10]; Language basics (2) Flow of control if, if-else, if-else if switch for, while, do-while break continue 7

Supplemental reading Getting Started http://java.sun.com/docs/books/tutorial/getstarted/index.html Nuts and bolts of the Java Language http://java.sun.com/docs/books/tutorial/java/nutsandbolts/index.html Compiling and Running a Simple Program http://developer.java.sun.com/developer/onlinetraining/programming/basic Java1/compile.html 8