A Java introduction SDK, FC 15/12/2009 UMR AMAP. SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

Size: px
Start display at page:

Download "A Java introduction SDK, FC 15/12/2009 UMR AMAP. SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50"

Transcription

1 A Java introduction SDK, FC UMR AMAP 15/12/2009 SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

2 Plan 1 Introduction 2 Bases Java Application Variables & Expressions Simple Arrays Exceptions Collections Control structure Functions 3 Objects Classes Inheritance Polymorphism 4 Java standard library 5 To go further SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

3 History James Gosling and Sun Microsystems Java, May 20, 1995 Java 1 Java 6 GPL with classpath exception since 2006 SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

4 Characteristics Object Oriented Interpreted (need a virtual machine) Portable (Linux, Mac, Windows) Dynamic (introspection) Static typing (checks during compilation) Simplier than C++ (memory management, pointers, headers...) SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

5 Programming environment Java Environnment JRE (Java runtime environment) JDK (Java Development Kit) Jave SE (Standard edition) Java EE (Enterprise edition Web) Java ME (Micro edition) IDE - Editor Eclipse, NetBeans : Full IDE (completion, compilation...) Simple Editors : Notepad++, TextPad, Scite (coloration, indentation) SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

6 Installation Windows Download and install the last JDK (Java SE 6) Environment variable (Computer properties) Add to PATH variable the bin directory eg : C :/Program Files/Java/jdk1.6.0 version/bin Install editor TextPad or Notepad++ Linux sudo apt-get install sun-java6-jdk sudo apt-get remove openjdk-6-jdk Editor : use scite or gedit SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

7 Java application Java programs written in files with extension.java Applications are.java files with public static void main(...) method Compile and run Java application Run the compiler on a.java file : javac package/myprogram.java Produce a file of Java byte code : MyProgram.class Run the interperter on a.class file : java package.myprogram the tools javac java are part of the JDK SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

8 Workflow SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

9 Hello world package h e l l o ; / A p p l i c a t i o n H e l l o w o r l d / p u b l i c c l a s s H e l l o W o r l d { / Main Funcion / s t a t i c p u b l i c v o i d main ( S t r i n g [ ] a r g s ) { // p r i n t to s c r e e n System. out. p r i n t l n ( " Hello world!" ) ; Print to console : System.out.println( a string ) ; Commands finish with a ; Comments : // or /* */ Package : hello = directory java hello.helloworld SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

10 Create a new application Copy directory Rename directory and file : class Name and file name should be identical The package is a namespace and corresponds to the directories package name and directory should be identical Exercice : Create a new application package1.app1 SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

11 Variable & Simple type Variable A variable has a type and hold a value or an Object A variable name starts with lowercase, eg : myvariable ; boolean : true or false int : signed integer 32 bits long : signed integer 64 bits float : floating point 32 bits double : floating point 64 bits Object : a generic object initialization by default : 0 int avariable = 2 ; float anothervariable = 3.56f ; Use final for constants : final float CONSTANT = 0.1f ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

12 Operators Arithmetic +, -, *, /, % myint++, otherint ; +=, -=, *=, /=... Precedence : use parenthesis () division 2 / 3 different of 2.0 / 3.0 Division par zero Infinity or NaN Exercise : arithmetic.dividebyzero SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

13 Math import java.lang.math Constante : Math.PI, Math.E Math.abs(), Math.pow(), Math.sqrt(), Math.exp(), Math.log(), Math.cos(), Math.tan()... Math.toDegrees(), Math.toRadians() Javadoc : Java Math Exercice : Calculate triangle hypothenus with pythagore SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

14 Simple Arrays One or 2 dimensions arrays Dynamic allocation : new keyword null if not initialized Not resizable Access with [] operator Index begin at 0 S t r i n g [ ] a r r a y 1 a = new S t r i n g [ 1 2 ] ; S t r i n g [ ] a r r a y 1 b = {" toto ", " tata ", " titi " ; i n t s i z e = 4 ; double [ ] a r r a y 1 c = new double [ s i z e ] ; double [ ] [ ] a r r a y 2 = new double [ 4 ] [ 6 ] ; a r r a y 1 a [ 1 1 ] = "a string " ; a r r a y 2 [ 0 ] [ 2 ] = 3d ; a r r a y 2 [ 3 ] [ 5 ] = 1d ; System. out. p r i n t l n ( a r r a y 2 [ 4 ] [ 6 ] ) ; // i n d e x e r r o r SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

15 Error during execution Try to use an object not initialized Try to acces to a non exisiting element in array double [ ] a r r a y = n u l l ; System. out. p r i n t l n ( a r r a y. l e n g t h ) ; a r r a y = new double [ 1 0 ] ; System. out. p r i n t l n ( a r r a y [ 1 0 ] ) ; Exceptions are raised and stop the program SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

16 Exceptions Error can be catched anywhere in the program Specific exceptions can be raised double [ ] a r r a y = n u l l ; t r y { System. out. p r i n t l n ( a r r a y. l e n g t h ) ; catch ( E x c e p t i o n e ) { System. e r r. p r i n t l n ( e ) ; t r y { double r e s u l t = a r r a y [ 1 0 ] ; catch ( E x c e p t i o n e ) { r e s u l t = 0. ; System. out. p r i n t l n ( " Result : " + r e s u l t ) ; // i f ( r e s u l t < 0) { throw new E x c e p t i o n ( r e s u l t cannot be n e g a t i v e ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

17 Complex types Java manipulates Objects An object is a concept (e.g a particular data structure) Objects are instantiated with the keyword new A variable contains a reference to an object Affectation is a reference copy (the variable point to the same object) Objects are destroyed when there is no reference on it By default an object variable is set to null Objects have properties and methods accessible with the. operator MyObject o1, o2 ; // n u l l ; o1 = new MyObject ( ) ; o1. v a l u e ; o1. sum ( ) ; o2 = o1 ; o1 = n u l l ; o2 = n u l l ; // O bject w i l l be d e s t r o y e d by t h e garbage c o l l e c t o r SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

18 Collections Collections are dynamic containers Associated to a specific type Specific behaviour : list, set, map.. Simple types (int, float, double...) are not objects need a wrapper int Integer float Float double Double Collection class has method to sort, shuffle, reverse,... collections See javadoc : Collection java 1.6 C o l l e c t i o n <S t r i n g> c1 ; C o l l e c t i o n <I n t e g e r > c2 ; C o l l e c t i o n <Double> c2 ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

19 ArrayList An ordered collection of variable size Growth automatically get, add and set method Insertion is slow For a stack or a queue, use LinkedList List<String> l = new ArrayList<String >(); l. add ( " toto " ) ; l. add ( " tata " ) ; l. add ( " titi ", 1 ) ; // i n s e r t a t i n d e x 1 l. s e t ( 1, " tutu " ) ; // r e p l a c e a t i n d e x 1 l. s i z e ( ) ; // 3 l. g e t ( 0 ) ; // t o t o... SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

20 HashSet An unordered collection without duplicated elements contains method is fast Set<String> s = new HashSet<String >(); s. add ( " toto " ) ; s. add ( " tata " ) ; s. add ( " titi " ) ; s. add ( " toto " ) ; // f a l s e s. s i z e ( ) ; // 3 s. c o n t a i n s ( " tutu " ) ; // f a l s e... SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

21 HashMap Map associate a key with an object a key should be unique (like in a Set) Map<String, Color> m = new HashMap<String, Color >(); m. put ( " black ", new C o l o r ( 0, 0, 0 ) ) ; m. put ( " red ", new C o l o r ( 1, 0, 0 ) ) ; m. put ( " green ", new C o l o r ( 0, 1, 0 ) ) ; m. put ( " blue ", new C o l o r ( 0, 0, 1 ) ) ; m. g e t ( " red " ) ; // r e t u r n a c o l o r o b j e c t m. c o n t a i n s K e y ( " black " ) ; // t r u e m. k e y S e t ( ) ; // s e t o f k e y s SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

22 Boolean arithmetic boolean v = true ;! && <= >= < > ==!= == and equals() : reference vs contents!= and!equals() use () for precedence SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

23 if else Simple condition Can be combined // s i m p l e i f i f ( c o n d i t i o n ) { b l o c k // complex i f i f ( c o n d i t i o n ) { b l o c k 1 e l s e i f ( o t h e r c o n d i t i o n ) { b l o c k 2 e l s e { b l o c k 3 i f ( v1 &&! v2 ) { System. out. p r i n t l n ( "v1 and not v2" ) ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

24 while Loop with condition i n t c o u n t e r = 0 ; w h i l e ( c o u n t e r < 100 ) { System. out. p r i n t l n ( " counter : " + c o u n t e r ) ; c o u n t e r ++; i n t c o u n t e r 2 = 0 ; i n t sum = 0 ; w h i l e ( c o u n t e r 2 < 100) { sum += Math. random ( ) ; i f ( sum > 20) { break ; c o u n t e r += 1 ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

25 for Loop with index // With an a r r a y i n t [ ] a r r a y = new a r r a y [ 1 2 ] ; i n t sum = 0 ; f o r ( i n t i =0; i<a r r a y. l e n g t h ; i ++) { sum += a r r a y [ i ] ; Loop in a collection // With a l i s t List<Integer> l = new ArrayList<Integer >(); i n t sum = 0 ; f o r ( I n t e g e r v : l ) { sum += v ; // With a Map Map<String, Object> m = new HashMap<String, Object >(); f o r ( S t r i n g key : m. k e y S e t ( ) ) { System. out. p r i n t l n (m. g e t ( key ) ) ; Exercice : do the sum of a double array SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

26 Enumeration A enumeration is a type with a limited number of value Type checking Better than using integer or constante values // Type d e c l a r a t i o n enum StopLight {red, amber, green ; // Use t y p e StopLigth s ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

27 static Functions Like a mathematical function Reuse a block of code Inputs Parameters : type + variable name Output : return type s t a t i c double afunction ( double param1, double param2 ) { r e t u r n param1 param1 + param2 ; param1 and param2 are the parameters their names have a local scope : they are only available in the function double a = 2 ; double b = 3 ; double r e s u l t = a F u n c t i o n ( a, b ) ; // a F u n c t i o n ( 2, 3 ) System. out. p r i n t l n ( r e s u l t ) ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

28 Functions (2) a class can contain several functions if no parameters use () if no return type use void p u b l i c c l a s s MyClass { public s t a t i c double function1 ( double param1, double param2 ) {... p u b l i c s t a t i c v o i d f u n c t i o n 2 ( ) {... p u b l i c s t a t i c v o i d main ( S t r i n g [ ] a r g s ) {... SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

29 Read a file Scanner tool parses a list of token import j a v a. u t i l. Scanner ;... // i n a f u n c t i o n Scanner sc = new Scanner (new F i l e ( " filename.txt " ) ) ; w h i l e ( s c. hasnext ( ) ) { S t r i n g s = s c. n e x t ( ) ; // r e a d a s t r i n g i n t i = s c. n e x t I n t ( ) ; // r e a d an i n t f l o a t f = s c. n e x t F l o a t ( ) ; // r e a d a f l o a t // Read i n t h e s h e l l Scanner sc2 = new Scanner ( System. in ) ; System. out. p r i n t ( " Input a string : " ) ; S t r i n g s = s c 2. n e x t ( ) ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

30 Exercices Create a file with a list of number : numbers.txt Create a application which read the file in an ArrayList of Float ArrayList<Float> Compute the mean (and the variance) of the data Put the code in a function Use args argument in main to pass the filename in the command line Use the function to compute the mean for multiple files Try to put strings in the file and recover it Remove minimal and maximal values in the mean... SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

31 Object Oriented programming Java manipulates Objects E.g : a list, a number, a car, a species, a plant, a plot... Concepts Class : a type of object Instance : a real object Instance data : the data an object contains Data are different for each instanciated object Methods : the functions associated to an object SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

32 How to use Object Object are instanciated with the new keyword We can instantiate several objects of the same type Tree t1 = new Tree ( " Spruce " ) ; // i n i t i a l i z a t i o n w i t h p a r a m e t e r Tree t2 = new Tree ( " Larch " ) ; Tree t3 = new Tree ( "Fir " ) ; // each insta nce has i t s own data t1. getspeciesname ( ) ; // Spruce t2. getspeciesname ( ) ; // Larch t3. getspeciesname ( ) ; // F i r // P r o p e r t i e s t3. h e i g h t = 2 ; System. out. p r i n t l n ( t1. h e i g h t ) ; // Methods t2. setspeciesname ( " Spruce " ) ; // t2!= t1 but t2. e q u a l s ( t1 ) // a f f e c t a t i o n t3 = t1 ; // t3 and t1 p o i n t to t h e same o b j e c t t3 == t1 t3. getspeciesname ( ) ; // Spruce SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

33 Class A class is a type description It contains data and methods (members) p u b l i c c l a s s Tree { p u b l i c double height ; p r i v a t e S t r i n g speciesname ; // C o n s t r u c t o r s p u b l i c Tree ( String n ) { speciesname = n ; // A c c e s s o r s p u b l i c v o i d setspeciesname ( String n ) { speciesname = n ; p u b l i c S t r i n g getspeciesname ( ) { r e t u r n speciesname ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

34 Class... Access control Public : no access restriction Private : only accessible in the class method Protected : accessible in the class methods and in the subclasses Constructor Called when the object is created Can take parameters or not Can be declined in different versions No return type SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

35 Exercices tree/tree.java Add a private data : diameter Add corresponding accessor Add a method which return the volume of the trunk (we consider a cylinder) Create an application which use this class and this function SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

36 This this keyword represents the current object Usefull if there is ambiguity with the names p u b l i c c l a s s Tree {... / Volume o f t h e t r u n k / p u b l i c double getvolume ( ) { double volume ; double r a d i u s = t h i s. d i a m e t e r / 2d ; volume = r a d i u s r a d i u s 2d Math. PI t h i s. h e i g h t ; r e t u r n volume ; ;... SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

37 static static members are associated to the type static datas are shared by all instance static methods are not attached to an instance c l a s s Tree {... s t a t i c p u b l i c i n t s h a r e d s t a t i c public double g e t S u r f a c e ( double d i a m e t e r ) { double r a d i u s = d i a m e t e r / 2d ; double s u r f a c e = r a d i u s r a d i u s 2d Math. PI ; r e t u r n s u r f a c e ;... Tree. g e t S u r f a c e ( 2. ) Tree. s h a r e d SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

38 Inheritance We can reuse a class to make more specific classes e.g : a tree with crown, a tree with leaves, etc... Inheritance corresponds to a is a relation A sub-class has all the data and methods of its parent All class inherit from the class Object Multiple inheritance is not allowed SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

39 Inheritance // Tree. j a v a c l a s s Tree { // e x t e n d s O b ject p r o t e c t e d double height ; / C o n s t r u c t o r / p u b l i c Tree ( double h ) { h e i g h t = h ; p u b l i c double getheight ( ) ; // CrownTree. j a v a c l a s s CrownTree extends Tree { p r o t e c t e d double crownheigth ; p r o t e c t e d double crowndiameter ; / C o n s t r u c t o r / p u b l i c CrownTree ( double h, double ch, double cd ) { s u p e r ( h ) ; // p a r e n t c o n s t r u c t o r crownheigth = ch ; crowndiameter = cd ; p u b l i c double getcrownvolume ( ) {... SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

40 instanceof All class inherit from Object instanceof tests the type of an object Tree t = new Tree (10d ) ; CrownTree ct = new CrownTree (10d, 4d, 4d ) ; c t i n s t a n c e o f CrownTree ; // t r u e c t i n s t a n c e o f Tree ; // t r u e ct i n s t a n c e o f Object ; // t r u e t i n s t a n c e o f Tree ; // t r u e t i n s t a n c e o f CrownTree ; // f a l s e SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

41 Cast We can use the parent type in the code ( is a relation) we use a cast, when we have to change the type to a subtype a cast can fail Tree t1 = new Tree (10d ) ; Tree t2 = new CrownTree (10d, 4d, 4d ) ; t1. getcrownvolume ( ) ; // f a i l : not a c r o w n t r e e t2. getcrownvolume ( ) ; // f a i l : j a v a t h i n k i t i s a Tree CrownTree ct1 = ( CrownTree ) t2 ; // ok c t 1. getcrownvolume ( ) ; // ok CrownTree ct1 = ( CrownTree ) t1 ; // f a i l : t1 i s not a CrownTree SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

42 Override Method can be overriden in sub-class Use c l a s s Tree { / Tree growth / public void growth ( i n t nbyear ) { diameter += nbyear dbhinc ; / Tree w i t h crown / c l a s s CrownTree extends Tree { / Tree growth / public void growth ( i n t nbyear ) { s u p e r. growth ( nbyear ) ; crowndiameter += nbyear crowninc ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

43 Interface An interface is a kind of contract A class can implement several interface (multiple inheritance) An interface do not provide any implementation An interface is a type // Growthable. j a v a i n t e r f a c e Growthable { p u b l i c v o i d growth ( i n t n b y e a r ) ; // Tree. j a v a c l a s s Tree implements Growthable, Cloneable { public void growth ( i n t nbyear ) { // do growth p u b l i c Object c l o n e ( ) { // do c l o n e Growthable g = new Tree (... ) ; g. growth ( 1 0 ) ; g. g e t D i a m e t e r ( ) ; // e r r o r : j a v a don t know i f i t i s a Tree SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

44 Abstract class An abstract class is an incomplete class It cannot be instantiated Like an interface but with some implementation Can be useful to share common methods in an inheritance graph c l a s s abstract A b s t r a c t T r e e { p r i v a t e double height ; p r i v a t e double diameter ; p u b l i c double getvolume ( ) { double volume ; double r a d i u s = t h i s. d i a m e t e r / 2d ; r e t u r n = r a d i u s r a d i u s 2d Math. PI t h i s. h e i g h t ; a b s t r a c t i n t getnbleaves ( ) ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

45 Abstract class Each sub-class implements abstract methods c l a s s TreeWithNbLeaves extends A b s t r a c t T r e e { private i n t nbleaves O v e r r i d e i n t getnbleaves ( ) { r e t u r n nbleaves ; c l a s s T r e e W i t h L i s t O f L e a v e s extends A b s t r a c t T r e e { p r i v a t e L i s t <Leaf> l e a v e s O v e r r i d e i n t getnbleaves ( ) { r e t u r n l e a v e s. s i z e ( ) ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

46 Polymorphism Polymorphism means that we can use an object without knowing its exact type The correct function will be called List<AbstractTree> l = new ArrayList<AbstractTree >(); l. add ( new TreeWithNbLeaves ( ) ) ; l. add (new TreeWithListOfLeaves ( ) ) ; f o r ( AbstractTree t : l ) { System. out. p r i n t l n ( "nb leaves : " + t. getnbleaves ( ) ) ; SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

47 Exercices In the tree package Create the sub-class CrownTree Add a method to compule the volume of the CrownTree Create 2 sub-classes SphericTree and ConicTree Override the volume function Create a class Forest containing a list of trees Add function to build a random forest Compute the volume of the forest SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

48 Java library See javadoc : http ://java.sun.com/javase/6/docs/api/ GUI Math Data Structure (Collections) Input Output Networking MultiThreading Database Intropection SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

49 Apache commons libraries See web : http ://commons.apache.org/ Math IO Loggin CLI Collections... SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

50 Some links Sun s tutorials : http ://java.sun.com/docs/books/tutorial/ Coding conventions : http ://java.sun.com/docs/codeconv/html/codeconvtoc.doc.html Resources on Capsis web site : http ://capsis.cirad.fr Millions of books... SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

ITI Introduction to Computing II

ITI Introduction to Computing II (with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 11, 2015 Please don t print these lecture notes unless you really need to!

More information

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name:

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name: CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : If a child overrides

More information

ITI Introduction to Computing II

ITI Introduction to Computing II (with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 9, 2019 Please don t print these lecture notes unless you really need to!

More information

SFWR ENG/COMP SCI 2S03 Principles of Programming

SFWR ENG/COMP SCI 2S03 Principles of Programming (Slide 1 of 78) Dr. Ridha Khedri Department of Computing and Software, McMaster University Canada L8S 4L7, Hamilton, Ontario Acknowledgments: Material based on Java actually: A Comprehensive Primer in

More information

CS-140 Fall 2018 Test 2 Version Practice Nov. 12, Name:

CS-140 Fall 2018 Test 2 Version Practice Nov. 12, Name: CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, or F if the statement is false. (a) T F : If a child overrides its parent

More information

Computer Science Introductory Course MSc - Introduction to Java

Computer Science Introductory Course MSc - Introduction to Java Computer Science Introductory Course MSc - Introduction to Java Lecture 1: Diving into java Pablo Oliveira ENST Outline 1 Introduction 2 Primitive types 3 Operators 4 5 Control Flow

More information

import java. u t i l. ;... Scanner sc = new Scanner ( System. in ) ;

import java. u t i l. ;... Scanner sc = new Scanner ( System. in ) ; CPSC 490 Input Input will always arrive on stdin. You may assume input is well-formed with respect to the problem specification; inappropriate input (e.g. text where a number was specified, number out

More information

2 Getting Started with Numerical Computations in Python

2 Getting Started with Numerical Computations in Python 1 Documentation and Resources * Download: o Requirements: Python, IPython, Numpy, Scipy, Matplotlib o Windows: google "windows download (Python,IPython,Numpy,Scipy,Matplotlib" o Debian based: sudo apt-get

More information

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ;

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ; 1 Trees The next major set of data structures belongs to what s called Trees. They are called that, because if you try to visualize the structure, it kind of looks like a tree (root, branches, and leafs).

More information

CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018

CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018 CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, or F if the statement is false. (a) T X F : If a child overrides its parent

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 6:

CMSC 132, Object-Oriented Programming II Summer Lecture 6: CMSC 132, Object-Oriented Programming II Summer 2016 Lecturer: Anwar Mamat Lecture 6: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 6.1 Singly

More information

Python. chrysn

Python. chrysn Python chrysn 2008-09-25 Introduction Structure, Language & Syntax Strengths & Weaknesses Introduction Structure, Language & Syntax Strengths & Weaknesses Python Python is an interpreted,

More information

Lecture 5: Sep. 23 &25

Lecture 5: Sep. 23 &25 CIS 2168 Data Structures Fall 2014 Lecturer: Anwar Mamat Lecture 5: Sep. 23 &25 Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 5.1 Doubly Linked

More information

MATHEMATICAL OBJECTS in

MATHEMATICAL OBJECTS in MATHEMATICAL OBJECTS in Computational Tools in a Unified Object-Oriented Approach Yair Shapira @ CRC Press Taylor & Francis Group Boca Raton London New York CRC Press is an imprint of the Taylor & Francis

More information

DM507 - Algoritmer og Datastrukturer Project 1

DM507 - Algoritmer og Datastrukturer Project 1 DM507 - Algoritmer og Datastrukturer Project 1 Christian Skjøth Mat-Øk 280588 Morten Olsen Mat-Øk 090789 19. marts 2012 Task 1 - Double for-loop So, first we needed to create an instance of the class File

More information

Course Announcements. John Jannotti (cs32) Scope, Collections & Generics Feb 8, / 1

Course Announcements. John Jannotti (cs32) Scope, Collections & Generics Feb 8, / 1 Course Announcements Stars is due tomorrow. Stars grades should be out by next Monday. Javascript lab out today. How you make interactive webby GUIs. Today we re going to cover a bit of a hodge podge.

More information

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion: German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Rimon Elias Dr. Hisham Othman Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:

More information

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany Softwaretechnik Lecture 13: Design by Contract Peter Thiemann University of Freiburg, Germany 25.06.2012 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented

More information

Python. Tutorial. Jan Pöschko. March 22, Graz University of Technology

Python. Tutorial. Jan Pöschko. March 22, Graz University of Technology Tutorial Graz University of Technology March 22, 2010 Why? is: very readable easy to learn interpreted & interactive like a UNIX shell, only better object-oriented but not religious about it slower than

More information

Extensibility Patterns: Extension Access

Extensibility Patterns: Extension Access Design Patterns and Frameworks Dipl.-Medieninf. Christian Piechnick INF 2080 christian.piechnick@tu-dresden.de Exercise Sheet No. 5 Software Technology Group Institute for SMT Department of Computer Science

More information

CS 163/164 - Exam 1 Study Guide and Practice Exam

CS 163/164 - Exam 1 Study Guide and Practice Exam CS 163/164 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Strings...................................................

More information

Compiling Techniques

Compiling Techniques Lecture 7: Abstract Syntax 13 October 2015 Table of contents Syntax Tree 1 Syntax Tree Semantic Actions Examples Abstract Grammar 2 Internal Representation AST Builder 3 Visitor Processing Semantic Actions

More information

CS Java. Introduction to Java. Andy Mroczkowski Department of Computer Science Drexel University

CS Java. Introduction to Java. Andy Mroczkowski Department of Computer Science Drexel University CS 190 - Java Introduction to Java Andy Mroczkowski uamroczk@cs.drexel.edu Department of Computer Science Drexel University February 18, 2008 / Lecture 5 Outline Course Status Course Information & Schedule

More information

Lab Exercise 6 CS 2334

Lab Exercise 6 CS 2334 Lab Exercise 6 CS 2334 September 28, 2017 Introduction In this lab, you will experiment with using inheritance in Java through the use of abstract classes and interfaces. You will implement a set of classes

More information

Modern Functional Programming and Actors With Scala and Akka

Modern Functional Programming and Actors With Scala and Akka Modern Functional Programming and Actors With Scala and Akka Aaron Kosmatin Computer Science Department San Jose State University San Jose, CA 95192 707-508-9143 akosmatin@gmail.com Abstract For many years,

More information

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion: German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:

More information

public void run ( ) { i f ( this. id == 0) System. out. p r i n t ( 3 ) ; bro. j o i n ( ) ; else System. out. p r i n t ( 2 ) ;

public void run ( ) { i f ( this. id == 0) System. out. p r i n t ( 3 ) ; bro. j o i n ( ) ; else System. out. p r i n t ( 2 ) ; 1 Unusual programs 1. Consider the following Java program : public c l a s s Thread2 extends Thread { public int id ; public Thread2 bro ; public Thread2 ( int id, Thread2 bro ) { this. id = id ; this.

More information

CS Exam 3 Study Guide and Practice Exam

CS Exam 3 Study Guide and Practice Exam CS 163 - Exam 3 Study Guide and Practice Exam November 6, 2017 Summary 1 Disclaimer 2 Methods and Data 2.1 Static vs. Non-Static........................................... 2.1.1 Static Example..........................................

More information

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany Softwaretechnik Lecture 13: Design by Contract Peter Thiemann University of Freiburg, Germany 25.06.2012 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented

More information

1 ListElement l e = f i r s t ; / / s t a r t i n g p o i n t 2 while ( l e. next!= n u l l ) 3 { l e = l e. next ; / / next step 4 } Removal

1 ListElement l e = f i r s t ; / / s t a r t i n g p o i n t 2 while ( l e. next!= n u l l ) 3 { l e = l e. next ; / / next step 4 } Removal Präsenzstunden Today In the same room as in the first week Assignment 5 Felix Friedrich, Lars Widmer, Fabian Stutz TA lecture, Informatics II D-BAUG March 18, 2014 HIL E 15.2 15:00-18:00 Timon Gehr (arriving

More information

Introduction to Programming (Java) 3/12

Introduction to Programming (Java) 3/12 Introduction to Programming (Java) 3/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

More information

1. Write a program to calculate distance traveled by light

1. Write a program to calculate distance traveled by light G. H. R a i s o n i C o l l e g e O f E n g i n e e r i n g D i g d o h H i l l s, H i n g n a R o a d, N a g p u r D e p a r t m e n t O f C o m p u t e r S c i e n c e & E n g g P r a c t i c a l M a

More information

BoardGame: A MiniDraw extension

BoardGame: A MiniDraw extension BoardGame: A MiniDraw extension Henrik Bærbak Christensen Status: Draft. November 29, 2010 Chapter 1 Boardgame Architecture The MiniDraw framework is described in Chapter 30 in Flexible, Reliable Software.

More information

INTRODUCTION. This is not a full c-programming course. It is not even a full 'Java to c' programming course.

INTRODUCTION. This is not a full c-programming course. It is not even a full 'Java to c' programming course. C PROGRAMMING 1 INTRODUCTION This is not a full c-programming course. It is not even a full 'Java to c' programming course. 2 LITTERATURE 3. 1 FOR C-PROGRAMMING The C Programming Language (Kernighan and

More information

Instance Methods and Inheritance (1/2)

Instance Methods and Inheritance (1/2) Instance Methods and Inheritance (1/2) 1 class Professor { 2 p u b l i c void say_hello ( ) { 3 System. out. p r i n t l n ( " Hello! " ) ; 4 } 5 } 6 class CSIEProfessor extends Professor { 7 p u b l i

More information

Voortgezet Programmeren

Voortgezet Programmeren Voortgezet Programmeren Lecture 4: Interfaces and polymorphism Tommi Tervonen Econometric Institute, Erasmus School of Economics Rule #1: never duplicate code p u b l i c c l a s s Course { p u b l i c

More information

Anatomy of SINGULAR talk at p. 1

Anatomy of SINGULAR talk at p. 1 Anatomy of SINGULAR talk at MaGiX@LIX 2011- p. 1 Anatomy of SINGULAR talk at MaGiX@LIX 2011 - Hans Schönemann hannes@mathematik.uni-kl.de Department of Mathematics University of Kaiserslautern Anatomy

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 12

CMSC 132, Object-Oriented Programming II Summer Lecture 12 CMSC 132, Object-Oriented Programming II Summer 2016 Lecturer: Anwar Mamat Lecture 12 Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 12.1 Trees

More information

Introduction to Computing II (ITI1121) FINAL EXAMINATION

Introduction to Computing II (ITI1121) FINAL EXAMINATION Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of engineering School of Electrical Engineering and Computer Science Identification

More information

Computer Science Introductory Course MSc - Introduction to Java

Computer Science Introductory Course MSc - Introduction to Java Computer Science Introductory Course MSc - Introduction to Java Lecture 3:,, Pablo Oliveira ENST Outline 1 2 3 Definition An exception is an event that indicates an abnormal condition

More information

Introduction to Computing II (ITI 1121) FINAL EXAMINATION

Introduction to Computing II (ITI 1121) FINAL EXAMINATION Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of engineering School of Electrical Engineering and Computer Science Identification

More information

Lisp Introduction. Dr. Neil T. Dantam. Spring CSCI-498/598 RPM, Colorado School of Mines. Dantam (Mines CSCI, RPM) Lisp Spring / 88

Lisp Introduction. Dr. Neil T. Dantam. Spring CSCI-498/598 RPM, Colorado School of Mines. Dantam (Mines CSCI, RPM) Lisp Spring / 88 Lisp Introduction Dr. Neil T. Dantam CSCI-498/598 RPM, Colorado School of Mines Spring 28 Dantam (Mines CSCI, RPM) Lisp Spring 28 / 88 Outline Lisp Common Lisp by Example Implementation Details Typing

More information

Binary Search Trees. Motivation

Binary Search Trees. Motivation Binary Search Trees Motivation Searching for a particular record in an unordered list takes O(n), too slow for large lists (databases) If the list is ordered, can use an array implementation and use binary

More information

SFWR ENG 3S03: Software Testing

SFWR ENG 3S03: Software Testing (Slide 1 of 69) Dr. Ridha Khedri Writing in Department of Computing and Software, McMaster University Canada L8S 4L7, Hamilton, Ontario Acknowledgments: Material based on [HT03] Unit Testing in Java with

More information

Assignment 4: Object creation

Assignment 4: Object creation Assignment 4: Object creation ETH Zurich Hand-out: 13 November 2006 Due: 21 November 2006 Copyright FarWorks, Inc. Gary Larson 1 Summary Today you are going to create a stand-alone program. How to create

More information

Notater: INF3331. Veronika Heimsbakk December 4, Introduction 3

Notater: INF3331. Veronika Heimsbakk December 4, Introduction 3 Notater: INF3331 Veronika Heimsbakk veronahe@student.matnat.uio.no December 4, 2013 Contents 1 Introduction 3 2 Bash 3 2.1 Variables.............................. 3 2.2 Loops...............................

More information

Go Tutorial. Ian Lance Taylor. Introduction. Why? Language. Go Tutorial. Ian Lance Taylor. GCC Summit, October 27, 2010

Go Tutorial. Ian Lance Taylor. Introduction. Why? Language. Go Tutorial. Ian Lance Taylor. GCC Summit, October 27, 2010 GCC Summit, October 27, 2010 Go Go is a new experimental general purpose programming language. Main developers are: Russ Cox Robert Griesemer Rob Pike Ken Thompson It was released as free software in November

More information

Software Engineering

Software Engineering Software Engineering Lecture 07: Design by Contract Peter Thiemann University of Freiburg, Germany 02.06.2014 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented

More information

Sharing Objects. Pieter van den Hombergh. Fontys Hogeschool voor Techniek en Logistiek. February 15, 2017

Sharing Objects. Pieter van den Hombergh. Fontys Hogeschool voor Techniek en Logistiek. February 15, 2017 Pieter van den Hombergh Fontys Hogeschool voor Techniek en Logistiek February 15, 2017 and /FHTenL February 15, 2017 is safe Idioms 1/34 and and is safe Idioms /FHTenL February 15, 2017 2/34 visibility

More information

n CS 160 or CS122 n Sets and Functions n Propositions and Predicates n Inference Rules n Proof Techniques n Program Verification n CS 161

n CS 160 or CS122 n Sets and Functions n Propositions and Predicates n Inference Rules n Proof Techniques n Program Verification n CS 161 Discrete Math at CSU (Rosen book) Sets and Functions (Rosen, Sections 2.1,2.2, 2.3) TOPICS Discrete math Set Definition Set Operations Tuples 1 n CS 160 or CS122 n Sets and Functions n Propositions and

More information

ASSIGNMENT 2 TIPS AND TRICKS

ASSIGNMENT 2 TIPS AND TRICKS ROBERT SEDGEWICK KEVIN WAYNE ASSIGNMENT 2 TIPS AND TRICKS n-body simulation problem decomposition the physics bugs universes http://introcs.cs.princeton.edu Alan Kaplan and Kevin Wayne Last updated on

More information

Functional Programming with F# Overview and Basic Concepts

Functional Programming with F# Overview and Basic Concepts Functional Programming with F# Overview and Basic Concepts Radu Nicolescu Department of Computer Science University of Auckland 27 Sep 2017 1 / 52 1 Background 2 Overview 3 Type System and Type Inference

More information

Comp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 40

Comp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 40 Comp 11 Lectures Mike Shah Tufts University July 26, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 26, 2017 1 / 40 Please do not distribute or host these slides without prior permission. Mike

More information

SDS developer guide. Develop distributed and parallel applications in Java. Nathanaël Cottin. version

SDS developer guide. Develop distributed and parallel applications in Java. Nathanaël Cottin. version SDS developer guide Develop distributed and parallel applications in Java Nathanaël Cottin sds@ncottin.net http://sds.ncottin.net version 0.0.3 Copyright 2007 - Nathanaël Cottin Permission is granted to

More information

Algorithms for Uncertainty Quantification

Algorithms for Uncertainty Quantification Technische Universität München SS 2017 Lehrstuhl für Informatik V Dr. Tobias Neckel M. Sc. Ionuț Farcaș April 26, 2017 Algorithms for Uncertainty Quantification Tutorial 1: Python overview In this worksheet,

More information

Übung Informatik I - Programmierung - Blatt 7

Übung Informatik I - Programmierung - Blatt 7 RHEINISCH- WESTFÄLISCHE TECHNISCHE HOCHSCHULE AACHEN LEHR- UND FORSCHUNGSGEBIET INFORMATIK II RWTH Aachen D-52056 Aachen GERMANY http://programmierung.informatik.rwth-aachen.de LuFG Informatik II Prof.

More information

DARN: A Matrix Manipulation Language

DARN: A Matrix Manipulation Language DARN: A Matrix Manipulation Language Daisy Chaussee (dac2183) Anthony Kim (ak3703) Rafael Takasu (rgt2108) Ignacio (Nacho) Torras (it2216) December 20, 2016 1 Contents 1 Introduction to the Language 4

More information

AlgAE (Algorithm Animation Engine) Reference Manual Version 3.0. Steven J. Zeil Old Dominion University Dept. of Computer Science

AlgAE (Algorithm Animation Engine) Reference Manual Version 3.0. Steven J. Zeil Old Dominion University Dept. of Computer Science AlgAE (Algorithm Animation Engine) Reference Manual Version 3.0 Steven J. Zeil Old Dominion University Dept. of Computer Science August 20, 2011 i Copyright: This document is c 2011, Steven J. Zeil. Permission

More information

Tou has been released!

Tou has been released! Tou has been released! Shoot- em-up, heavy use of collision detection Much more open-ended than previous projects Easier than previous projects if you work smart Should help those of you combating the

More information

Java Programming. Final Examination on December 13, 2015 Fall 2015

Java Programming. Final Examination on December 13, 2015 Fall 2015 Java Programming Final Examination on December 13, 2015 Fall 2015 Department of Computer Science and Information Engineering National Taiwan University Problem 1 (10 points) Multiple choice questions.

More information

MiniMat: Matrix Language in OCaml LLVM

MiniMat: Matrix Language in OCaml LLVM Terence Lim - tl2735@columbia.edu August 17, 2016 Contents 1 Introduction 4 1.1 Goals........................................ 4 1.1.1 Flexible matrix notation......................... 4 1.1.2 Uncluttered................................

More information

Introduction to ANTLR (ANother Tool for Language Recognition)

Introduction to ANTLR (ANother Tool for Language Recognition) Introduction to ANTLR (ANother Tool for Language Recognition) Jon Eyolfson University of Waterloo September 27 - October 1, 2010 Outline Introduction Usage Example Demonstration Conclusion Jon Eyolfson

More information

Lecture 5: Jun. 10, 2015

Lecture 5: Jun. 10, 2015 CMSC 132, Object-Oriented Programming II Summer 2015 Lecturer: Anwar Mamat Lecture 5: Jun. 10, 2015 Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor.

More information

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015 CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Catie Baker Spring 2015 Today Registration should be done. Homework 1 due 11:59pm next Wednesday, April 8 th. Review math

More information

Writing Bots for Maize

Writing Bots for Maize Writing Bots for Maize Stephen Wattam November 1, 2012 Contents 1 Introduction 2 2 World Format 2 3 Bot API 2 3.1 Bot Data Format.................................... 3 3.2 Alternative Interfaces to Bot.............................

More information

Elementary Sorts 1 / 18

Elementary Sorts 1 / 18 Elementary Sorts 1 / 18 Outline 1 Rules of the Game 2 Selection Sort 3 Insertion Sort 4 Shell Sort 5 Visualizing Sorting Algorithms 6 Comparing Sorting Algorithms 2 / 18 Rules of the Game Sorting is the

More information

CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis. Hunter Zahn Summer 2016

CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis. Hunter Zahn Summer 2016 CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis Hunter Zahn Summer 2016 Today Finish discussing stacks and queues Review math essential to algorithm analysis Proof by

More information

CS Exam 1 Study Guide and Practice Exam

CS Exam 1 Study Guide and Practice Exam CS 150 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Suggestions, Warnings, and Resources.................................

More information

Generics. Hsuan-Tien Lin. OOP Class, May 23, Department of CSIE, NTU. H.-T. Lin (NTU CSIE) Generics OOP 05/23/ / 16

Generics. Hsuan-Tien Lin. OOP Class, May 23, Department of CSIE, NTU. H.-T. Lin (NTU CSIE) Generics OOP 05/23/ / 16 Generics Hsuan-Tien Lin Department of CSIE, NTU OOP Class, May 23, 2013 H.-T. Lin (NTU CSIE) Generics OOP 05/23/2013 0 / 16 How can we write a class for an Integer set of arbitrary size? H.-T. Lin (NTU

More information

1 Java Night Countdown (30%)

1 Java Night Countdown (30%) Midterm Examination Problem Sheet TIME: 04/18/2009, 19:00 21:00 This is a open-textbook exam. You can use the Absolute Java textbook as your reference during the exam. Any other references are not allowed.

More information

Outline. PeerSim: Informal introduction. Resources. What is PeerSim? Alberto Montresor Gianluca Ciccarelli

Outline. PeerSim: Informal introduction. Resources. What is PeerSim? Alberto Montresor Gianluca Ciccarelli Outline PeerSim: Informal introduction Alberto Montresor Gianluca Ciccarelli Networking group - University of Trento April 3, 2009 1 2 files structure 3 1 / 45 2 / 45 Resources What is PeerSim? These slides

More information

Octave. Tutorial. Daniel Lamprecht. March 26, Graz University of Technology. Slides based on previous work by Ingo Holzmann

Octave. Tutorial. Daniel Lamprecht. March 26, Graz University of Technology. Slides based on previous work by Ingo Holzmann Tutorial Graz University of Technology March 26, 2012 Slides based on previous work by Ingo Holzmann Introduction What is? GNU is a high-level interactive language for numerical computations mostly compatible

More information

CSE P503 - Project 1: Navigation System.

CSE P503 - Project 1: Navigation System. CSE P503 - Project 1: Navigation System. 1. Introduction The goal of this project is to design and verify a probe navigation system. Assume a radio telescope (marked by the red dot) sits at the center

More information

DEBUGGING AND TESTING WITH SCALACHECK. Martina Seidl 2017/11/14

DEBUGGING AND TESTING WITH SCALACHECK. Martina Seidl 2017/11/14 DEBUGGING AND TESTING WITH SCALACHECK Martina Seidl 2017/11/14 Some Words on Scala Scala is object-oriented every value is an object classes and traits: types and behavior of objects inheritance Scala

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 11:

CMSC 132, Object-Oriented Programming II Summer Lecture 11: CMSC 132, Object-Oriented Programming II Summer 2016 Lecturer: Anwar Mamat Lecture 11: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 11.1 Recursion

More information

Android Services. Lecture 4. Operating Systems Practical. 26 October 2016

Android Services. Lecture 4. Operating Systems Practical. 26 October 2016 Android Services Lecture 4 Operating Systems Practical 26 October 2016 This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.

More information

Introduction to ASM - ByteCode Manipulating Tool

Introduction to ASM - ByteCode Manipulating Tool Introduction to ASM - ByteCode Manipulating Tool nadeesh.tv@oracle.com ORACLE India Pvt Ltd 19 March 2016 Outline 1 Why do we need a byte code manipulating tool? 2 Compiled Class File Structure 3 ASM Why

More information

Richard Gibson CSC 421 Assignment #4 Apr. 4, 2006 #

Richard Gibson CSC 421 Assignment #4 Apr. 4, 2006 # Richard Gibson CSC 421 Assignment #4 Apr. 4, 26 #235677 Probability Theory Suppose that we are given cipher texts which encode messages in such a way that each letter of the alphabet is mapped to a sequence

More information

Sun SPOTs: A Great Solution for Small Device Development

Sun SPOTs: A Great Solution for Small Device Development Sun SPOTs: A Great Solution for Small Device Development Claudio M. Horvilleur Cromasoft, S.A. de C.V. México Agenda What is the Problem? What is a SunSPOT? Adding a New Sensor Hardware Development Issues

More information

Python Tutorial on Reading in & Manipulating Fits Images and Creating Image Masks (with brief introduction on DS9)

Python Tutorial on Reading in & Manipulating Fits Images and Creating Image Masks (with brief introduction on DS9) 1 Tyler James Metivier Professor Whitaker Undergrad. Research February 26, 2017 Python Tutorial on Reading in & Manipulating Fits Images and Creating Image Masks (with brief introduction on DS9) Abstract:

More information

AMS 132: Discussion Section 2

AMS 132: Discussion Section 2 Prof. David Draper Department of Applied Mathematics and Statistics University of California, Santa Cruz AMS 132: Discussion Section 2 All computer operations in this course will be described for the Windows

More information

Determining an Optimal Parenthesization of a Matrix Chain Product using Dynamic Programming

Determining an Optimal Parenthesization of a Matrix Chain Product using Dynamic Programming Determining an Optimal Parenthesization of a Matrix Chain Product using Dynamic Programming Vivian Brian Lobo 1, Flevina D souza 1, Pooja Gharat 1, Edwina Jacob 1, and Jeba Sangeetha Augestin 1 1 Department

More information

Lecture 4: Stacks and Queues

Lecture 4: Stacks and Queues Reading materials Goodrich, Tamassia, Goldwasser (6th), chapter 6 OpenDSA (https://opendsa-server.cs.vt.edu/odsa/books/everything/html/): chapter 9.8-13 Contents 1 Stacks ADT 2 1.1 Example: CharStack ADT

More information

Introduction to Python and its unit testing framework

Introduction to Python and its unit testing framework Introduction to Python and its unit testing framework Instructions These are self evaluation exercises. If you know no python then work through these exercises and it will prepare yourself for the lab.

More information

ENS Lyon Camp. Day 5. Basic group. C October

ENS Lyon Camp. Day 5. Basic group. C October ENS Lyon Camp. Day 5. Basic group. C++. 30 October Contents 1 Input/Output 1 1.1 C-style.......................................... 1 1. C++-style........................................ Stack Overflow

More information

Google Go illustrated on the basis of Fibonacci numbers

Google Go illustrated on the basis of Fibonacci numbers Google Go illustrated on the basis of Fibonacci numbers Jan Pennekamp RWTH University Aachen Chair for Data Management and Data Exploration Prof. Dr. T. Seidl Supervision: Dipl.-Ing. Marwan Hassani Friday,

More information

Constructors - Cont. must be distinguished by the number or type of their arguments.

Constructors - Cont. must be distinguished by the number or type of their arguments. Constructors - Cont. 1 Constructors can be overloaded! must be distinguished by the number or type of their arguments. 2 When no constructor is defined, there is a default constructor with no arguments.

More information

ISSP User Guide CY3207ISSP. Revision C

ISSP User Guide CY3207ISSP. Revision C CY3207ISSP ISSP User Guide Revision C Cypress Semiconductor 198 Champion Court San Jose, CA 95134-1709 Phone (USA): 800.858.1810 Phone (Intnl): 408.943.2600 http://www.cypress.com Copyrights Copyrights

More information

Växjö University. Software Security Testing. A Flexible Architecture for Security Testing. School of Mathematics and System Engineering

Växjö University. Software Security Testing. A Flexible Architecture for Security Testing. School of Mathematics and System Engineering School of Mathematics and System Engineering Reports from MSI - Rapporter från MSI Växjö University Software Security Testing A Flexible Architecture for Security Testing Martin Andersson Aug 2008 MSI

More information

Introduction to the Go Programming Language

Introduction to the Go Programming Language Introduction to the Go Programming Language Fabian Wenzelmann August 1, 2017 F. Wenzelmann Introduction to Go August 1, 2017 1 / 126 Why Go? What is Go? Go is a programming language developed at Google

More information

Problem Decomposition: One Professor s Approach to Coding

Problem Decomposition: One Professor s Approach to Coding Problem Decomposition: One Professor s Approach to Coding zombie[1] zombie[3] Fewer Buuuuugs zombie[4] zombie[2] zombie[5] zombie[0] Fundamentals of Computer Science I Overview Problem Solving Understand

More information

ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University

ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University Prof. Mi Lu TA: Ehsan Rohani Laboratory Exercise #4 MIPS Assembly and Simulation

More information

Data Structures and Algorithms Winter Semester

Data Structures and Algorithms Winter Semester Page 0 German University in Cairo December 26, 2015 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher Dr. Wael Abouelsadaat Data Structures and Algorithms Winter Semester 2015-2016 Final

More information

CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture CS429: Computer Organization and Architecture Warren Hunt, Jr. and Bill Young Department of Computer Sciences University of Texas at Austin Last updated: September 3, 2014 at 08:38 CS429 Slideset C: 1

More information

R: A Quick Reference

R: A Quick Reference R: A Quick Reference Colorado Reed January 17, 2012 Contents 1 Basics 2 1.1 Arrays and Matrices....................... 2 1.2 Lists................................ 3 1.3 Loading Packages.........................

More information

Auto-Tuning Complex Array Layouts for GPUs - Supplemental Material

Auto-Tuning Complex Array Layouts for GPUs - Supplemental Material BIN COUNT EGPGV,. This is the author version of the work. It is posted here by permission of Eurographics for your personal use. Not for redistribution. The definitive version is available at http://diglib.eg.org/.

More information

Project 3: Hadoop Blast Cloud Computing Spring 2017

Project 3: Hadoop Blast Cloud Computing Spring 2017 Project 3: Hadoop Blast Cloud Computing Spring 2017 Professor Judy Qiu Goal By this point you should have gone over the sections concerning Hadoop Setup and a few Hadoop programs. Now you are going to

More information

INF Models of concurrency

INF Models of concurrency INF4140 - Models of concurrency Fall 2017 October 17, 2017 Abstract This is the handout version of the slides for the lecture (i.e., it s a rendering of the content of the slides in a way that does not

More information

More About Methods. Hsuan-Tien Lin. Deptartment of CSIE, NTU. OOP Class, March 8-9, 2010

More About Methods. Hsuan-Tien Lin. Deptartment of CSIE, NTU. OOP Class, March 8-9, 2010 More About Methods Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 8-9, 2010 H.-T. Lin (NTU CSIE) More About Methods OOP 03/08-09/2010 0 / 24 Methods: the Basic Method (1/2, Callee s View) 1 p

More information

Administrivia. Course Objectives. Overview. Lecture Notes Week markem/cs333/ 2. Staff. 3. Prerequisites. 4. Grading. 1. Theory and application

Administrivia. Course Objectives. Overview. Lecture Notes Week markem/cs333/ 2. Staff. 3. Prerequisites. 4. Grading. 1. Theory and application Administrivia 1. markem/cs333/ 2. Staff 3. Prerequisites 4. Grading Course Objectives 1. Theory and application 2. Benefits 3. Labs TAs Overview 1. What is a computer system? CPU PC ALU System bus Memory

More information