CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX

Slides:



Advertisements
Similar presentations
What Is Java? The name Java is a trademark of Sun Microsystems
Advertisements

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.
Introduction to Programming G51PRG University of Nottingham Revision 1
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Object Orientated Programming
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
Introduction to Java Programming
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Netprog 2002 Java Intro1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network.
Hello, world! Dissect HelloWorld.java Compile it Run it.
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.
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
CSC3170 Introduction to Database Systems
CS 11 C track: lecture 1 Preliminaries Need a CS cluster account cgi-bin/sysadmin/account_request.cgi Need to know UNIX ITS.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
DAT602 Database Application Development Lecture 5 JAVA Review.
1 CSC 201: Computer Programming I B. S. Afolabi. Introduction  3 unit course  2 hours of lecture/week Thursdays 4.00pm – 6.00pm Mondays 4.00pm – 6.00pm.
INTRODUCTION TO JAVA CHAPTER 1 1. WHAT IS JAVA ? Java is a programming language and computing platform first released by Sun Microsystems in The.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004.
Introduction to Computer Systems and the Java Programming Language.
POS 406 Java Technology And Beginning Java Code
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
CS591x A very brief introduction to Java. Java Developed by Sun Microsystems was intended a language for embedded applications became a general purpose.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Java Programming Presented by Daniel Rosenthal Friday, November 30 th, 2007.
Introduction to java Prepared By:-Pragnesh Patel Lect. In Computer Dept. NSIT,Jetalpur 1.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
1 Introduction to Java. 2 What is Java? A programming language. A platform –A virtual machine (JVM) definition. –Runtime environments in diverse hardware.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
Fall 2015CISC124 - Prof. McLeod1 CISC124 Have you filled out the lab section survey? (As of last night 54 left to fill out the survey.) TA names have been.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CS 11 java track: lecture 2 This week: more on object-oriented programming (OOP) objects vs. primitive types creating new objects with new calling methods.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
Reference Learning Java DDC publishing Herst, Yamauchi, Adler COP 3331 Object Oriented Analysis and Design Java Part I.
Introduction to Java John Lewis. Course Overview Introduction Object Orientated Programming Java Structure and Syntax Using the Java Platform Advanced.
CSCI 212 Object-Oriented Programming in Java. Prerequisite: CSCI 111 variable assignment statement while loop for loop post-increment (i++) strong typing.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
Java Computer Industry Lab. 1 Programming Java Java Basics Incheon Paik.
ITP 109 Week 2 Trina Gregory Introduction to Java.
CS 106 Introduction to Computer Science I 01 / 24 / 2007 Instructor: Michael Eckmann.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
Object Oriented Programming Lecture 2: BallWorld.
Spring 2006 Special Topics in Computer Engineering: Java Intro 1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Information and Computer Sciences University of Hawaii, Manoa
CS210 Intermediate Computing with Data Structures (Java)
Intro to ETEC Java.
Introduction to.
Yanal Alahmad Java Workshop Yanal Alahmad
Internet and Java Foundations, Programming and Practice
Data types and variables
Programming Language Concepts (CIS 635)
Getting Started ARCS Lab..
(Computer fundamental Lab)
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
In this class, we will cover:
F II 2. Simple Java Programs Objectives
Presentation transcript:

CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX unix/unixtutorial.shtml track home page:

prerequisites some programming experience CS 1 ideal, not required familiarity with C syntax

assignments 1st assignment is posted now due one week after class, midnight late penalty: 1 mark/day redos

textbook, online tutorials Arnold, Gosling, Holmes: The Java Programming Language, 3rd. ed. earlier editions NOT acceptable java on-line tutorials: reallybigindex.html very good material!

what is java? java is an object-oriented programming language a programming environment a large set of libraries (java API) a philosophy

java philosophy programs should be portable "write once, run anywhere" programs should be safe no core dumps, no memory corruption programs should be easy to write and understand programs should be as efficient as possible subject to the above constraints

programming in java (1) version: java (on CS cluster) programmer writes source code files end in ".java" extension java compiler (javac) converts (compiles) source code into "bytecode" (files ending in ".class") bytecode is "machine code" for Java Virtual Machine (JVM)

programming in java (2) example: % javac Foo.java  Foo.class  (may compile other files too if "Foo.java" depends on them)

programming in java (3) JVM (program name: java) executes bytecode to run the program JVM implementations exist for most platforms (Windows, Linux, Mac...) % java Foo executes bytecode in Foo.class can be compiled to machine code on-the-fly

libraries java API (application programming interface) HUGE set of libraries, including graphics networking database input/output

the java language (1) "object oriented" object: data + functions acting on that data class: template for building objects; includes data (fields) that every object contains functions (methods) that can act on the object objects are instances of a particular class

the java language (2) all data is either an object i.e. an instance of some class a primitive data type int float, double char boolean

the java language (3) java is strongly, statically typed strongly typed: all data has a type statically typed: all types must be declared before use type declarations can occur anywhere in source code int foo; // foo has type int

the java language (4) methods have a name a set of arguments with their types a return type some optional modifiers methods written inside class definition methods have implicit extra argument: the object they're part of (called this)

"hello world" program (1) in file "HelloWorld.java": class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); }

"hello world" program (2) class definition: class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } file must be called "HelloWorld.java"

"hello world" program (3) method definition: class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); }

"hello world" program (4) method name: class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } program always starts executing with main

"hello world" program (5) method arguments: class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } String[] = array of strings (command line args)

"hello world" program (6) method return type: class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } void means "doesn't return anything"

"hello world" program (7) method modifiers: class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } we'll discuss these later

"hello world" program (8) method body: class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } print "Hello, world!" to the terminal (System.out)

"hello world" program (9) compile: % javac HelloWorld.java  HelloWorld.class run: % java HelloWorld Hello, world! %

data types int  integers float  single precision floating point double  double precision floating point char  Unicode characters (16 bit) boolean  true or false (not 0 or 1) byte  8 bits; "raw data" String  character strings

operators like in C: + - * / % = = -= etc. precedence: a + b * c  a + (b * c) NOT (a + b) * c use parentheses if need to override defaults

comments three kinds: // This comment goes to the end of the line. /* This comment can span * multiple lines. */ /** * This comment is for documentation. */

conditionals if / else if / else like in C: int i = 10; if (i < 20) { System.out.println("less than 20"); } else if (i == 20) { System.out.println("equal to 20"); } else { System.out.println("greater than 20"); }

loops (1) for and while loops like in C: int i; for (i = 0; i < 10; i++) { // do something with i } while (i < 20) { // do something with i // increment i }

loops (2) can declare types at first use: for (int i = 0; i < 10; i++) { // do something with i } now "i" only usable inside the loop judgment call; usually the right thing to do

that's all for now this is enough for 1 st assignment lots more to come!