Kontejnery. Březen 2008
|
|
|
- Gwenda McDaniel
- 10 years ago
- Views:
Transcription
1 Seminář Java Kontejnery Radek Kočí Fakulta informačních technologií VUT Březen 2008 Radek Kočí Seminář Java Kontejnery 1/ 53
2 Téma přednášky Kontejnery For-each loop Autoboxing Radek Kočí Seminář Java Kontejnery 2/ 53
3 Příklad public class Car {... public int run(int km) {... public class Driver { protected String name; protected Car drivercar; public void drivecar(car c) { drivecar = c; drivecar.drivenby(this); Radek Kočí Seminář Java Kontejnery 3/ 53
4 Příklad Radek Kočí Seminář Java Kontejnery 4/ 53
5 Příklad Radek Kočí Seminář Java Kontejnery 5/ 53
6 Kontejnery Kontejnery (containers) v Javě slouží k ukládání objektů (ne hodnot primitivních typů!) verze < 5.0 kontejnery jsou koncipovány jako beztypové verze => 5.0 kontejnery nesou typovou informaci o prvcích Většinou se používají kontejnery hotové, vestavěné (součást Java Core API): vestavěné kontejnerové třídy jsou definovány v balíku java.util je možné vytvořit si vlastní implementace, obvykle ale zachovávající/implementující standardní rozhraní Radek Kočí Seminář Java Kontejnery 6/ 53
7 Kontejnery K čemu slouží? jsou dynamickými alternativami k poli a mají daleko širší použití k uchování proměnného počtu objektů počet prvků se v průběhu existence kontejneru může měnit oproti polím nabízejí časově efektivnější algoritmy přístupu k prvkům Radek Kočí Seminář Java Kontejnery 7/ 53
8 Kontejnery Základní kategorie kontejnerů seznam (List) lineární struktura množina (Set) struktura bez uspořádání, rychlé dotazování na přítomnost prvku asociativní pole, mapa (Map) struktura uchovávající dvojice klíč hodnota, rychlý přístup přes klíč Radek Kočí Seminář Java Kontejnery 8/ 53
9 Kontejnery Kontejnery rozhraní, nepovinné metody Funkcionalita vestavěných kontejnerů je obvykle předepsána výhradně rozhraním, které implementují. Rozhraní však připouštějí, že některé metody jsou nepovinné, třídy jej nemusí implementovat (optional operations)! V praxi se totiž někdy nehodí implementovat jak čtecí, tak i zápisové operace některé kontejnery jsou read-only Radek Kočí Seminář Java Kontejnery 9/ 53
10 Kontejnery rozhraní Radek Kočí Seminář Java Kontejnery 10/ 53
11 Kontejnery implementace rozhraní hash table resizable balanced linked list array tree Set HashSet TreeSet List ArrayList LinkedList Map HashMap TreeMap SortedSet SortedMap Uvedené kontejnery implementují všechny optional operace povolují null elementy (klíče, hodnoty) jsou nesynchronizované Radek Kočí Seminář Java Kontejnery 11/ 53
12 Kontejnery souběžný přístup, výjimky Moderní kontejnery jsou nesynchronizované, nepřipouštějí souběžný přístup z více vláken. Standardní, nesynchronizovaný, kontejner lze však zabalit synchronizovanou obálkou. Při práci s kontejnery může vzniknout řada výjimek, např. IllegalStateException apod. Většina má charakter výjimek běhových, není povinností je odchytávat pokud věříme, že nevzniknou. Radek Kočí Seminář Java Kontejnery 12/ 53
13 Kolekce Kolekce jsou kontejnery implementující rozhraní Collection (viz API doc k rozhr. Collection) Rozhraní kolekce popisuje velmi obecný kontejner, disponující operacemi: přidávání, rušení prvku, získání iterátoru, zjišťování prázdnosti atd. Mezi kolekce patří mimo Map všechny ostatní vestavěné kontejnery List, Set Prvky kolekce nemusí mít svou pozici danou indexem viz např. Set Radek Kočí Seminář Java Kontejnery 13/ 53
14 Kontejnery Java public interface List extends Collection {... public boolean add(object o); public Object get(int index); při vybírání elementu z kolekce musíme přetypovat není hlídáno kompilátorem pouze dynamická typová kontrola šance na vygenerování run-time výjimky Radek Kočí Seminář Java Kontejnery 14/ 53
15 Kontejnery Java 5.0 Generics (vlastnost Java 5.0) public interface List<E> extends Collection<E> {... public boolean add(e o); public E get(int index); umožňuje komunikaci s kompilátorem statická kontrola typů při manipulaci s kontejnery bez přetypování! Radek Kočí Seminář Java Kontejnery 15/ 53
16 Iterátory Iterátory jsou prostředkem, jak chodit po prvcích kolekce buďto v neurčeném pořadí nebo v uspořádání (u uspořádaných kolekcí) Každý iterátor musí implementovat velmi jednoduché rozhraní Iterator se třemi metodami: boolean hasnext() Object next() (resp. E next()) void remove() Radek Kočí Seminář Java Kontejnery 16/ 53
17 Seznamy Seznamy lineární struktury implementují rozhraní List prvky lze adresovat indexem (typu int) poskytují možnost získat dopředný i zpětný iterátor lze pracovat i s podseznamy Standardní implementace ArrayList LinkedList Radek Kočí Seminář Java Kontejnery 17/ 53
18 Seznamy Příklad public class Run { protected Driver driver; protected Car car; protected int km;... public class Car { protected List runs = new ArrayList();... public int run(driver d, int km) { runs.add(new Run(d, this, km)); Radek Kočí Seminář Java Kontejnery 18/ 53
19 Seznamy Příklad public class Car { protected List runs = new ArrayList();... public int run(driver d, int km) { runs.add(new Run(d, this, km)); public iterate() { for (Iterator i = seznam.iterator(); i.hasnext(); ) { Run r = (Run)i.next(); r.getdriver();... Radek Kočí Seminář Java Kontejnery 19/ 53
20 Seznamy příklad (Generics 5.0) Při překladu předchozího kódu: Note: ListDemo2.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. javac -Xlint:unchecked ListDemo2.java ListDemo2.java:9: warning: [unchecked] unchecked call to add(e) as a member of the raw type java.util.list seznam.add(new Run(d, this, km));... Radek Kočí Seminář Java Kontejnery 20/ 53
21 Seznamy Příklad (Generics 5.0) public class Car { protected List<Run> runs = new ArrayList<Run>();... public int run(driver d, int km) { runs.add(new Run(d, this, km)); public iterate() { for (Iterator<Run> i = seznam.iterator(); i.hasnext(); ) { Run r = i.next(); r.getdriver();... Radek Kočí Seminář Java Kontejnery 21/ 53
22 Seznamy Příklad (Generics 5.0) public class Car { protected List<Run> runs = new ArrayList<Run>();... public int run(driver d, int km) { runs.add(new Run(d, this, km)); public iterate() { ListIterator<Run> it = seznam.listiterator(1); Run r; r = it.previous(); r = it.next();... Radek Kočí Seminář Java Kontejnery 22/ 53
23 The For-Each Loop (Java 5.0) void cancelall(collection<timertask> c) { for (Iterator<TimerTask> i = c.iterator(); i.hasnext(); ) { TimerTask t = i.next(); t.cancel(); for (TimerTask t : c ) { t.cancel(); Radek Kočí Seminář Java Kontejnery 23/ 53
24 The For-Each Loop (Java 5.0) List suits, ranks =...; List sorteddeck = new ArrayList(); // BROKEN - throws NoSuchElementException! for (Iterator i = suits.iterator(); i.hasnext(); ) for (Iterator j = ranks.iterator(); j.hasnext(); ) sorteddeck.add(new Card(i.next(), j.next())); // Fixed, though a bit ugly for (Iterator i = suits.iterator(); i.hasnext(); ) { Suit suit = (Suit) i.next(); for (Iterator j = ranks.iterator(); j.hasnext(); ) sorteddeck.add(new Card(suit, j.next())); Radek Kočí Seminář Java Kontejnery 24/ 53
25 The For-Each Loop (Java 5.0) List suits =...; List ranks =...; List sorteddeck = new ArrayList(); for (Suit suit : suits) for (Rank rank : ranks) sorteddeck.add(new Card(suit, rank)); Radek Kočí Seminář Java Kontejnery 25/ 53
26 Množiny Množiny struktury standardně bez uspořádání prvků (uspořádané viz dále) implementují rozhraní Set (což je rozšíření Collection) Cílem množin je mít možnost rychle (se složitostí O(log(n))) provádět atomické operace: vkládání prvku (add) odebírání prvku (remove) dotaz na přítomnost prvku (contains) lze testovat i relaci je podmnožinou Standardní implementace HashSet hašovací tabulka TreeSet vyhledávací strom Radek Kočí Seminář Java Kontejnery 26/ 53
27 Množiny příklad Set<Driver> mnozina = new HashSet<Driver>(); Driver d1 = new Driver("Pepa"); Driver d2 = new Driver("Franta"); mnozina.add(d1); mnozina.add(d2); System.out.println("Je v mnozine Franta?" + mnozina.contains(d2)); Radek Kočí Seminář Java Kontejnery 27/ 53
28 Množiny (equals a hashcode) Set<Driver> mnozina = new HashSet<Driver>(); Driver d1 = new Driver("Pepa"); Driver d2 = new Driver("Franta"); mnozina.add(d1); mnozina.add(d2); Driver d3 = new Driver("Franta"); System.out.println("Je v mnozine Franta?" + mnozina.contains(d3)); Radek Kočí Seminář Java Kontejnery 28/ 53
29 Množiny (equals a hashcode) class Driver { String name;... public boolean equals(object o) { if (o instanceof Driver) { Driver d = (Driver) o; return name.equals(d.name); else throw new IllegalArgumentException("..."); public int hashcode() { return name.hashcode(); Radek Kočí Seminář Java Kontejnery 29/ 53
30 Uspořádané množiny Uspořádané množiny Implementují rozhraní SortedSet (viz API doc k rozhraní SortedSet) Jednotlivé prvky lze tedy iterátorem procházet v přesně definovaném pořadí (uspořádání) podle hodnot prvků. Standardní implementace TreeSet vyhledávací Red-Black Trees Radek Kočí Seminář Java Kontejnery 30/ 53
31 Uspořádané množiny příklad SortedSet<Driver> mnozina = new TreeSet<Driver>(); Driver d1 = new Driver("Pepa"); Driver d2 = new Driver("Franta"); mnozina.add(d2); mnozina.add(d1); for (Driver d : mnozina) { d.getname(); Run-time vyjimka java.lang.classcastexception Radek Kočí Seminář Java Kontejnery 31/ 53
32 Uspořádané množiny komparátor Uspořádání je dáno: standardním chováním metody compareto vkládaných objektů pokud implementují rozhraní Comparable nebo je možné uspořádání definovat pomocí tzv. komparátoru (objektu impl. rozhraní Comparator) při vytvoření množiny. Radek Kočí Seminář Java Kontejnery 32/ 53
33 Uspořádané množiny komparátor (příklad) Implementace operace compareto public class Driver implements Comparable { String name;... public int compareto(object o) { if (o instanceof Driver) { Driver c = (Driver) o; return name.compareto(name); else throw new IllegalArgumentException("..."); Radek Kočí Seminář Java Kontejnery 33/ 53
34 Mapy Mapy (asociativní pole, nepřesně také hašovací tabulky nebo haše) fungují na stejných principech a požadavcích jako Set: avšak ukládají dvojice (klíč hodnota) a umožnují rychlé vyhledání dvojice podle hodnoty klíče, základními metodami jsou: dotazy na přítomnost klíče v mapě (containskey), výběr hodnoty odpovídající zadanému klíči (get), možnost získat zvlášt množiny klíčů, hodnot nebo dvojic (klíč hodnota) Radek Kočí Seminář Java Kontejnery 34/ 53
35 Mapy Mapy mají: podobné implementace jako množiny (tj. hašovací tabulky nebo stromy) logaritmickou složitost základních operací put remove containskey Standardní implementace HashMap TreeMap Radek Kočí Seminář Java Kontejnery 35/ 53
36 Mapy příklad Map<String, Driver> mapa = new HashMap<String, Driver>(); Driver d1 = new Driver("Pepa"); Driver d2 = new Driver("Franta"); mapa.put(d1.getname(), d1); mapa.put(d2.getname(), d2); Driver d = mapa.get("pepa"); for (String name : mapa.keyset()) { mapa.get(name); Radek Kočí Seminář Java Kontejnery 36/ 53
37 Uspořádané mapy Uspořádané mapy Implementují rozhraní SortedMap Dvojice (klíč hodnota) jsou v nich uspořádané podle hodnot klíče. Uspořádání lze ovlivnit naprosto stejným postupem jako u uspořádané množiny. Standardní implementace TreeMap implementace Red-Black Trees Radek Kočí Seminář Java Kontejnery 37/ 53
38 Uspořádané mapy příklad SortedMap<String, Driver> mapa = new TreeMap<String, Driver>(); Driver d1 = new Driver("Pepa"); Driver d2 = new Driver("Franta"); mapa.put(d1.getname(), d1); mapa.put(d2.getname(), d2); for (String name : mapa.keyset()) { Driver d = mapa.get(name); Radek Kočí Seminář Java Kontejnery 38/ 53
39 Uspořádané mapy příklad Exception in thread "main" java.lang.classcastexception:... at java.util.treemap.compare(treemap.java:1093) at java.util.treemap.put(treemap.java:465) at seminar6.sortedmapdemo.main(sortedmapdemo.java Radek Kočí Seminář Java Kontejnery 39/ 53
40 Uspořádané mapy příklad s komparátorem SortedMap<Driver, Car> mapa = new TreeMap<Driver, Car>(new DComp()); Driver d1 = new Driver("Pepa"); Car c1 = new Car(); Driver d2 = new Driver("Franta"); Car c2 = new Car(); mapa.put(d1, c1); mapa.put(d2, c2); for (Driver d : mapa.keyset()) { Car c = mapa.get(d); // d ridi c Radek Kočí Seminář Java Kontejnery 40/ 53
41 Uspořádané mapy příklad s komparátorem class DComp implements Comparator { public int compare(object o1, Object o2) { // porovnava jen podle jmena if (o1 instanceof Driver && o2 instanceof Driver) { Driver c1 = (Driver)o1; Driver c2 = (Driver)o2; return c1.name.compareto(c2.name); else throw new IllegalArgumentException(".."); Radek Kočí Seminář Java Kontejnery 41/ 53
42 Srovnání implementací kontejnerů Seznamy na bázi pole (ArrayList) rychlý přímý přístup (přes index) na bázi lineárního zřetězeného seznamu (LinkedList) rychlý sekvenční přístup (přes iterátor) téměř vždy se používá ArrayList stejně rychlý a paměťově efektivnější Radek Kočí Seminář Java Kontejnery 42/ 53
43 Srovnání implementací kontejnerů Množiny a mapy na bázi hašovacích tabulek (HashMap, HashSet) rychlejší, ale neuspořádané (lze získat iterátor procházející klíče uspořádaně) na bázi vyhledávacích stromů (TreeMap, TreeSet) pomalejší, ale uspořádané spojení výhod obou LinkedHashSet, LinkedHashMap (novinka v Javě 2, v1.4) Radek Kočí Seminář Java Kontejnery 43/ 53
44 Historie Existují tyto starší typy kontejnerů ( náhrada) Hashtable HashMap, HashSet (podle účelu) Vector List Stack List Roli iterátoru plnil dříve výčet (enumeration) se dvěma metodami: boolean hasmoreelements() Object nextelement() Radek Kočí Seminář Java Kontejnery 44/ 53
45 Nemodifikovatelné kolekce Statické metody třídy Collections XXX unmodifiablexxx(xxx c); Set unmodifiableset(set c); Map unmodifiablemap(map c);... Radek Kočí Seminář Java Kontejnery 45/ 53
46 Nemodifikovatelné kolekce public class UnmodifiableDemo { public static void main(string[] args) { List seznam = new ArrayList(); seznam.add(new Integer(20)); seznam = Collections.unmodifiableList(seznam); System.out.println(seznam); seznam.add(new Integer(20)); Vyjimka UnsupportedOperationException Radek Kočí Seminář Java Kontejnery 46/ 53
47 Synchronizované kolekce Statické metody třídy Collections XXX synchronizedxxx(xxx c); Collection synchronizedset(collection c); Map synchronizedmap(map c);... Příště... Radek Kočí Seminář Java Kontejnery 47/ 53
48 The For-Each Loop (Java 5.0) // Returns the sum of the elements of a int sum(int[] a) { int result = 0; for (int i : a) result += i; return result; Radek Kočí Seminář Java Kontejnery 48/ 53
49 Objektová verze primitivních datových typů int Integer long Long short Short byte Byte char Character float Float double Double boolean Boolean void Void Double.MAX VALUE float f = Float.parseFloat(řetězec) Radek Kočí Seminář Java Kontejnery 49/ 53
50 Autoboxing (Java 5.0) // Prints a frequency table of the words // on the command line public class Frequency { public static void main(string[] args) { Map<String, Integer> m = new HashMap<String, Integer>(); for (String word : args) { Integer freq = m.get(word); m.put(word, (freq == null? new Integer(1) : new Integer(freq.intValue() + 1) )); System.out.println(m); Radek Kočí Seminář Java Kontejnery 50/ 53
51 Autoboxing (Java 5.0) public class Frequency { public static void main(string[] args) { Map<String, Integer> m = new HashMap<String, Integer>(); for (String word : args) { Integer freq = m.get(word); m.put(word, (freq == null? 1 : freq+1)); System.out.println(m); Radek Kočí Seminář Java Kontejnery 51/ 53
52 Autoboxing (Java 5.0) java Frequency if it is to be it is up to me to do {be=1, do=1, if=1, is=2, it=2, me=1, to=3, up=1 Radek Kočí Seminář Java Kontejnery 52/ 53
53 Odkazy Podrobné seznámení s kontejnery tutorial/collections/ Popis Java Radek Kočí Seminář Java Kontejnery 53/ 53
Class 32: The Java Collections Framework
Introduction to Computation and Problem Solving Class 32: The Java Collections Framework Prof. Steven R. Lerman and Dr. V. Judson Harward Goals To introduce you to the data structure classes that come
Data Structures in the Java API
Data Structures in the Java API Vector From the java.util package. Vectors can resize themselves dynamically. Inserting elements into a Vector whose current size is less than its capacity is a relatively
JAVA COLLECTIONS FRAMEWORK
http://www.tutorialspoint.com/java/java_collections.htm JAVA COLLECTIONS FRAMEWORK Copyright tutorialspoint.com Prior to Java 2, Java provided ad hoc classes such as Dictionary, Vector, Stack, and Properties
Collections in Java. Arrays. Iterators. Collections (also called containers) Has special language support. Iterator (i) Collection (i) Set (i),
Arrays Has special language support Iterators Collections in Java Iterator (i) Collections (also called containers) Collection (i) Set (i), HashSet (c), TreeSet (c) List (i), ArrayList (c), LinkedList
API for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list.
Sequences and Urns 2.7 Lists and Iterators Sequence. Ordered collection of items. Key operations. Insert an item, iterate over the items. Design challenge. Support iteration by client, without revealing
Generic Types in Java. Example. Another Example. Type Casting. An Aside: Autoboxing 4/16/2013 GENERIC TYPES AND THE JAVA COLLECTIONS FRAMEWORK.
Generic Types in Java 2 GENERIC TYPES AND THE JAVA COLLECTIONS FRAMEWORK Lecture 15 CS2110 Spring 2013 When using a collection (e.g., LinkedList, HashSet, HashMap), we generally have a single type T of
The Java Collections Framework
The Java Collections Framework Definition Set of interfaces, abstract and concrete classes that define common abstract data types in Java e.g. list, stack, queue, set, map Part of the java.util package
Working with Java Collections
Working with Java Collections Java 2 Collections Lists - linear, supporting many operations Sets - unordered, unique items Sorted sets - like sets, but items can be visited in sorted order Java 2 Collections
Basic Programming and PC Skills: Basic Programming and PC Skills:
Texas University Interscholastic League Contest Event: Computer Science The contest challenges high school students to gain an understanding of the significance of computation as well as the details of
Jazyk C# (seminář 8)
Jazyk C# (seminář 8) Pavel Procházka KMI 12. listopadu 2014 Na co je dobré XML? Deklarativní jazyk reprezentující čitelně data Snadná práce s konfiguračními soubory a ukládání do souboru Human readeble
D06 PROGRAMMING with JAVA
Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch20 Data Structures I PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for
core 2 Basic Java Syntax
core Web programming Basic Java Syntax 1 2001-2003 Marty Hall, Larry Brown: http:// Agenda Creating, compiling, and executing simple Java programs Accessing arrays Looping Using if statements Comparing
Konzepte objektorientierter Programmierung
Konzepte objektorientierter Programmierung Prof. Dr. Peter Müller Werner Dietl Software Component Technology Exercises 3: Some More OO Languages Wintersemester 04/05 Agenda for Today 2 Homework Finish
e ag u g an L g ter lvin v E ram Neal G g ro va P Ja
Evolving the Java Programming Language Neal Gafter Overview The Challenge of Evolving a Language Design Principles Design Goals JDK7 and JDK8 Challenge: Evolving a Language What is it like trying to extend
Java Coding Practices for Improved Application Performance
1 Java Coding Practices for Improved Application Performance Lloyd Hagemo Senior Director Application Infrastructure Management Group Candle Corporation In the beginning, Java became the language of the
CS 111 Classes I 1. Software Organization View to this point:
CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects
BIRD Internet Routing Daemon
BIRD Internet Routing Daemon Ondřej Zajíček CZ.NIC z.s.p.o. IT 13 Úvod I Úvod do dynamického routování I Představení démona BIRD I OSPF a BIRD I BGP a BIRD Dynamické routování I Sestavení routovacích tabulek
CSE 2123 Collections: Sets and Iterators (Hash functions and Trees) Jeremy Morris
CSE 2123 Collections: Sets and Iterators (Hash functions and Trees) Jeremy Morris 1 Collections - Set What is a Set? A Set is an unordered sequence of data with no duplicates Not like a List where you
Crash Course in Java
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 Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third
Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman
http://algs4.cs.princeton.edu dictionary find definition word definition book index find relevant pages term list of page numbers
ROBERT SEDGEWICK KEVI WAYE F O U R T H E D I T I O ROBERT SEDGEWICK KEVI WAYE ROBERT SEDGEWICK KEVI WAYE Symbol tables Symbol table applications Key-value pair abstraction. Insert a value with specified.
Paralelismus. Březen 2008
Seminář Java Paralelismus Radek Kočí Fakulta informačních technologií VUT Březen 2008 Radek Kočí Seminář Java Paralelismus 1/ 55 Obsah Vlákna Multithreading Sdílení prostředků Synchronizace Radek Kočí
AP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
cs2010: algorithms and data structures
cs2010: algorithms and data structures Lecture 11: Symbol Table ADT. Vasileios Koutavas 28 Oct 2015 School of Computer Science and Statistics Trinity College Dublin Algorithms ROBERT SEDGEWICK KEVIN WAYNE
Automatizovaná formální verifikace
Automatizovaná formální verifikace v operačních systémech Kamil Dudka 11. března 2010 Téma práce efektivní techniky pro verifikaci programů, které pracují s dynamickými datovými strukturami na vstupu bude
aneb Perfektní minulost.
aneb Perfektní minulost. 2013 se v angličtině nazývá Past Perfect. Používáme jej tehdy, potřebujeme-li jasně vyjádřit, že nějaký děj proběhl ještě dříve než minulý děj, o kterém hovoříme. Podívejme se
Java Cheatsheet. http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix
Java Cheatsheet http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix Hello World bestand genaamd HelloWorld.java naam klasse main methode public class HelloWorld
JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4
JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4 NOTE: SUN ONE Studio is almost identical with NetBeans. NetBeans is open source and can be downloaded from www.netbeans.org. I
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.
Arrays Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html 1 Grid in Assignment 2 How do you represent the state
CS 2112 Spring 2014. 0 Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions
CS 2112 Spring 2014 Assignment 3 Data Structures and Web Filtering Due: March 4, 2014 11:59 PM Implementing spam blacklists and web filters requires matching candidate domain names and URLs very rapidly
Introduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
STORM. Simulation TOol for Real-time Multiprocessor scheduling. Designer Guide V3.3.1 September 2009
STORM Simulation TOol for Real-time Multiprocessor scheduling Designer Guide V3.3.1 September 2009 Richard Urunuela, Anne-Marie Déplanche, Yvon Trinquet This work is part of the project PHERMA supported
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
Java Training - A Brief Summary of Objects
Java training An Introduction to Java dec 2010 Francois de Coligny Samuel Dufour INRA - UMR AMAP Botany and computational plant architecture Java training > contents Java training - Contents Introduction
Stacks and queues. Algorithms and Data Structures, Fall 2011. Rasmus Pagh. Based on slides by Kevin Wayne, Princeton
Algorithms and Data Structures, Fall 2011 Stacks and queues Rasmus Pagh Based on slides by Kevin Wayne, Princeton Algorithms, 4 th Edition Robert Sedgewick and Kevin Wayne Copyright 2002 2011 Stacks and
Java Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.
Scanner The Scanner class is intended to be used for input. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit. For example, suppose the input
Chapter 2 Introduction to Java programming
Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break
Neural networks in data mining
Neural networks in data mining Neuronové sítì v data mining A.VESELÝ Czech University of Agriculture, Prague, Czech Republic Abstract: To posses relevant information is an inevitable condition for successful
Upozorňujeme,že můžete formáty pro čtečky převádět ON-LINE na internetu do formátu PDF apod.
Dobrý den, děkujeme za Nákup,níže máte odkazy pro bezplatné stažení.knihy jsou v archivech PDF(nepotřebujete čtečku e-knih),txt(nepotřebujete čtečku e-knih), a dále pro čtečky : soubory typu: PDB,MOBI,APNX
Computer Programming I
Computer Programming I COP 2210 Syllabus Spring Semester 2012 Instructor: Greg Shaw Office: ECS 313 (Engineering and Computer Science Bldg) Office Hours: Tuesday: 2:50 4:50, 7:45 8:30 Thursday: 2:50 4:50,
Pemrograman Dasar. Basic Elements Of Java
Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle
The following program is aiming to extract from a simple text file an analysis of the content such as:
Text Analyser Aim The following program is aiming to extract from a simple text file an analysis of the content such as: Number of printable characters Number of white spaces Number of vowels Number of
Java Programming Fundamentals
Lecture 1 Part I Java Programming Fundamentals Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Introduction to Java We start by making a few
Practical Session 4 Java Collections
Practical Session 4 Java Collections Outline Working with a Collection The Collection interface The Collection hierarchy Case Study: Undoable Stack The Collections class Wrapper classes Collection A group
Economic efficiency of agricultural enterprises and its evaluation
Economic efficiency of agricultural enterprises and its evaluation Ekonomická efektivnost zemìdìlských podnikù a její hodnocení E. ROSOCHATECKÁ Czech University of Agriculture, Prague, Czech Republic Abstract:
1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders
1.00 Lecture 1 Course Overview Introduction to Java Reading for next time: Big Java: 1.1-1.7 Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
An Overview of Java. overview-1
An Overview of Java overview-1 Contents What is Java Major Java features Java virtual machine Java programming language Java class libraries (API) GUI Support in Java Networking and Threads in Java overview-2
Computer. Course Description
Computer Science Computer Science A Computer Science AB Course Description May 2009 The College Board: Connecting Students to College Success The College Board is a not-for-profit membership association
Example of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
CMSC 202H. ArrayList, Multidimensional Arrays
CMSC 202H ArrayList, Multidimensional Arrays What s an Array List ArrayList is a class in the standard Java libraries that can hold any type of object an object that can grow and shrink while your program
LINKED DATA STRUCTURES
LINKED DATA STRUCTURES 1 Linked Lists A linked list is a structure in which objects refer to the same kind of object, and where: the objects, called nodes, are linked in a linear sequence. we keep a reference
Java Map and Set collections
Java Map and Set collections Java Set container idea interface Java Map container idea interface iterator concordance example Java maps and sets [Bono] 1 Announcements Lab this week based on an example
CSC 551: Web Programming. Fall 2001
CSC 551: Web Programming Fall 2001 Java Overview! Design goals & features "platform independence, portable, secure, simple, object-oriented,! Language overview " program structure, public vs. private "instance
Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013
Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper
Design Patterns. Advanced Software Paradigms (A. Bellaachia) 1
Design Patterns 1. Objectives... 2 2. Definitions... 3 2.1. What is a Pattern?... 3 2.2. Categories of Patterns... 4 3. Pattern Characteristics [Buschmann]:... 5 4. Essential Elements of a Design Pattern
1.00 Lecture 35. Data Structures: Introduction Stacks, Queues. Reading for next time: Big Java: 15.1-15.3. Data Structures
1.00 Lecture 35 Data Structures: Introduction Stacks, Queues Reading for next time: Big Java: 15.1-15.3 Data Structures Set of reusable classes used in algorithms, simulations, operating systems, applications
Lecture 2: Data Structures Steven Skiena. http://www.cs.sunysb.edu/ skiena
Lecture 2: Data Structures Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena String/Character I/O There are several approaches
Chulalongkorn University International School of Engineering Department of Computer Engineering 2140105 Computer Programming Lab.
Chulalongkorn University Name International School of Engineering Student ID Department of Computer Engineering Station No. 2140105 Computer Programming Lab. Date Lab 2 Using Java API documents, command
09336863931 : provid.ir
provid.ir 09336863931 : NET Architecture Core CSharp o Variable o Variable Scope o Type Inference o Namespaces o Preprocessor Directives Statements and Flow of Execution o If Statement o Switch Statement
[email protected] [email protected]
Evolution of Linux network management InstallFest 2013, Praha http://data.pavlix.net/installfest/2013/ 1/12 From: Dan Williams To: networkmanager-list gnome org Subject: ANN: released
Quick Introduction to Java
Quick Introduction to Java Dr. Chris Bourke Department of Computer Science & Engineering University of Nebraska Lincoln Lincoln, NE 68588, USA Email: [email protected] 2015/10/30 20:02:28 Abstract These
Software Development with UML and Java 2 SDJ I2, Spring 2010
Software Development with UML and Java 2 SDJ I2, Spring 2010 Agenda week 7, 2010 Pakages Looking back Looking forward Packages Interfaces Page 1 Spring 2010 Download, Install/Setup 1. Java SE SDK (http://java.sun.com/javase/downloads)
ARP,TCP,IP utility -zjednodusene a rychle Jiri Kubina [email protected] Ver. 1.0 leden 2006
ARP,TCP,IP utility -zjednodusene a rychle Jiri Kubina Ver. 1.0 leden 2006 Obsah 1.ip 2.ifconfig 3.route 4.arp 5.arping 6.netstat 7.ethtool Upozorneni: U popisovanych prikazu nejsou uvedeny vsechny parametry
4.5 Symbol Table Applications
Set ADT 4.5 Symbol Table Applications Set ADT: unordered collection of distinct keys. Insert a key. Check if set contains a given key. Delete a key. SET interface. addkey) insert the key containskey) is
The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0
The following applies to all exams: Once exam vouchers are purchased you have up to one year from the date of purchase to use it. Each voucher is valid for one exam and may only be used at an Authorized
Problem 1. CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class
CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class This homework is to be done individually. You may, of course, ask your fellow classmates for help if you have trouble editing files,
Java 6 'th. Concepts INTERNATIONAL STUDENT VERSION. edition
Java 6 'th edition Concepts INTERNATIONAL STUDENT VERSION CONTENTS PREFACE vii SPECIAL FEATURES xxviii chapter i INTRODUCTION 1 1.1 What Is Programming? 2 J.2 The Anatomy of a Computer 3 1.3 Translating
Creating a Simple, Multithreaded Chat System with Java
Creating a Simple, Multithreaded Chat System with Java Introduction by George Crawford III In this edition of Objective Viewpoint, you will learn how to develop a simple chat system. The program will demonstrate
CS5233 Components Models and Engineering
Prof. Dr. Th. Letschert CS5233 Components Models and Engineering - Komponententechnologien Master of Science (Informatik) Java Management Extensions: JMX Seite 1 JMX http://download.oracle.com/javase/tutorial/jmx/index.html
Java in High-Performance Computing
Java in High-Performance Computing Dawid Weiss Carrot Search Institute of Computing Science, Poznan University of Technology GeeCon Poznań, 05/2010 Learn from the mistakes of others. You can t live long
Collections Classes for Real-Time and High-Performance Applications. July 4, 2005 Jean-Marie Dautelle
Collections Classes for Real-Time and High-Performance Applications July 4, 2005 Jean-Marie Dautelle Introduction The real-time specification for Java (RTSJ) aims to make your code more time predictable.
#820 Computer Programming 1A
Computer Programming I Levels: 10-12 Units of Credit: 1.0 CIP Code: 11.0201 Core Code: 35-02-00-00-030 Prerequisites: Secondary Math I, Keyboarding Proficiency, Computer Literacy requirement Semester 1
Programming Languages CIS 443
Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception
Java Interfaces. Recall: A List Interface. Another Java Interface Example. Interface Notes. Why an interface construct? Interfaces & Java Types
Interfaces & Java Types Lecture 10 CS211 Fall 2005 Java Interfaces So far, we have mostly talked about interfaces informally, in the English sense of the word An interface describes how a client interacts
Software Engineering Techniques
Software Engineering Techniques Low level design issues for programming-in-the-large. Software Quality Design by contract Pre- and post conditions Class invariants Ten do Ten do nots Another type of summary
COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005. Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19
Term Test #2 COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005 Family Name: Given Name(s): Student Number: Question Out of Mark A Total 16 B-1 7 B-2 4 B-3 4 B-4 4 B Total 19 C-1 4
CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
Contents. 9-1 Copyright (c) 1999-2004 N. Afshartous
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
Core Java+ J2EE+Struts+Hibernate+Spring
Core Java+ J2EE+Struts+Hibernate+Spring Java technology is a portfolio of products that are based on the power of networks and the idea that the same software should run on many different kinds of systems
Market Consistent Embedded Value
Market Consistent Embedded Value Dana Bohatová Chládková, Kamil Žák Seminář z aktuárských věd 4. května 2007 Obsah Proč Embedded Value? Co je Embedded Value? Market Consistent Embedded Value Vývoj EV Příklady
Introducing Variance into the Java Programming Language DRAFT
Introducing Variance into the Java Programming Language A Quick Tutorial DRAFT Christian Plesner Hansen Peter von der Ahé Erik Ernst Mads Torgersen Gilad Bracha June 3, 2003 1 Introduction Notice: This
Java the UML Way: Integrating Object-Oriented Design and Programming
Java the UML Way: Integrating Object-Oriented Design and Programming by Else Lervik and Vegard B. Havdal ISBN 0-470-84386-1 John Wiley & Sons, Ltd. Table of Contents Preface xi 1 Introduction 1 1.1 Preliminaries
TR 314 2R2 / J TR 311 Ö TR 313 TR 314 Ö TR 319 TR 331 Ö TR 336 TRA 25 Ö TRA 100 TR 323, TR 341-343
- p ehledovè daje - summary StandardnÌ sortiment Standard assortment TR 311 Ö TR 313 TR 314 Ö TR 319 TR 331 Ö TR 336 TR 314 2R2 / J ZatÌûenÌ L 1 Tolerance Hmotnost Strana katalogu Load (mm) Resistance
Evaluation. Copy. Evaluation Copy. Chapter 7: Using JDBC with Spring. 1) A Simpler Approach... 7-2. 2) The JdbcTemplate. Class...
Chapter 7: Using JDBC with Spring 1) A Simpler Approach... 7-2 2) The JdbcTemplate Class... 7-3 3) Exception Translation... 7-7 4) Updating with the JdbcTemplate... 7-9 5) Queries Using the JdbcTemplate...
Programmierpraktikum
Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 21 10/16/2012 09:29 AM Java - A First Glance 2 of 21 10/16/2012 09:29 AM programming languages
