PVS. Empirical Study of Usage and Performance of Java Collections. Diego Costa, 1 Artur Andrzejak, 1 Janos Seboek, 2 David Lo
|
|
- Anne Richard
- 5 years ago
- Views:
Transcription
1 Empirical Study of Usage and Performance of Java Collections Diego Costa, Artur Andrzejak, Janos Seboek, 2 David Lo Heidelberg University, 2 Singapore Management University PVS
2 Empirical Study of Usage and Performance of Java Collections Diego Costa, Artur Andrzejak, Janos Seboek, 2 David Lo Heidelberg University, 2 Singapore Management University Published as: Diego Costa, Artur Andrzejak, Janos Seboek, and David Lo Empirical Study of Usage and Performance of Java Collections. In Proceedings of the 8th ACM/SPEC on International Conference on Performance Engineering (ICPE '7), L'Aquila, Italy April 22-26, 207 Paper/slides available at: 2
3 Collections Collections are objects that groups multiple elements into a single unit. Use its metadata to track, access and manipulate its elements 2
4 Collections Collections are objects that groups multiple elements into a single unit. Use its metadata to track, access and manipulate its elements ArrayList<Integer> Object[] Integer 2
5 Collections Collections are objects that groups multiple elements into a single unit. Use its metadata to track, access and manipulate its elements ArrayList<Integer> Object[] Collection Overhead Elements Footprint Integer 2
6 Motivation Numerous studies have identified the inefficient use of collections as the main cause of runtime bloat Execution Time +7% Improv. Configuration of one HashMap instance [Liu et al. 2009] Memory Usage +54% Improv. Use of ArrayMaps instead of HashMaps [Ohad et al. 2009] Energy Consumption +00% Improv. Use of ArrayList instead of LinkedList [Jung et al. 206]
7 Collection Frameworks The Java Collection Framework offers a Standard implementation of the major collection abstractions Stable and reliable framework Easy to use However, there exist alternative libraries that provide a myriad of different implementations: Primitive Collections (IntArrayList) Immutable Collections Multimaps (Map<K, Collection>) Multisets (Map<K, int>) 4
8 Collection Frameworks The Java Collection Framework offers a Standard implementation of the major collection abstractions Stable and reliable framework Easy to use However, there exist alternative libraries that provide a myriad of different implementations: Primitive Collections (IntArrayList) Immutable Collections Multimaps (Map<K, Collection>) Multisets (Map<K, int>) Unsupported features 4
9 Collection Frameworks The Java Collection Framework offers a Standard implementation of the major collection abstractions Stable and reliable framework Easy to use However, there exist alternative libraries that provide a myriad of different implementations: Primitive Collections (IntArrayList) Immutable Collections Multimaps (Map<K, Collection>) Multisets (Map<K, int>) Unsupported features Simplified API 4
10 Analysis of Performance Impact of Alternative Collections Goal: Can we find alternatives to the Standard collection types which improve performance on time/memory?. Study on Collections Usage How often do programmers use alternative implementations? 2. Experimental Evaluation of popular Java Collection Libraries Are there better alternatives to the most commonly used Collections regarding performance? 5
11 Study on Usage of Collections Dataset We analyze the GitHub Java Corpus 0K projects 268 MLOC Static Analysis Use of Java Parser to extract variable declaration and allocation sites of Types with suffix: {List, Map, Set, Queue, Vector} Manually removed false-positives 6
12 Developers Rarely Use non-standard Collections HashMap 22% Maps 28% Sets 5% Lists 57% ArrayList 48% HashSet 0% 7
13 Developers Rarely Use non-standard Collections LinkedHashMap 2% HashMap 22% LinkedHashSet % Maps 28% Sets 5% Lists 57% ArrayList 48% HashSet 0% LinkedList 5% 8
14 Developers Rarely Use non-standard Collections TreeMap % LinkedHashMap 2% Other Maps % Top 4 represent 86% of all declared instantiations HashMap 22% Other Sets % LinkedHashSet TreeSet % HashSet 0% Maps 28% Sets 5% Other Lists 4% Lists 57% ArrayList 48% LinkedList 5% Non-Standard collections are declared <4% Evaluate alternatives to ArrayList, HashMap, HashSet and LinkedList 9
15 Commonly Used Element Data Types 00% 80% 60% 40% 20% 0% Top50 Lists Sets Map Keys Map Values Lists Sets Map Keys Map Values String Numeric Collections Other From the categorized data types: Strings are the most commonly held data type, followed by Numeric 0
16 Commonly Used Element Data Types 00% 80% 60% 40% 20% 0% Top50 Lists Sets Map Keys Map Values Lists Sets Map Keys Map Values String Numeric Collections Other From the categorized data types: Strings are the most commonly held data type, followed by Numeric Evaluate collections holding Strings, Integer and Long 0
17 Initial Capacity is Rarely Specified 00% Top50 80% 60% 40% 20% Specified Default Copy 0% ArrayList HashMap HashSet
18 Initial Capacity is Rarely Specified 00% Top50 80% 60% 40% 20% Specified Default Copy Evaluate collections with default Initial Capacity 0% ArrayList HashMap HashSet
19 Superior Alternatives Superior Alternative: a Non-Standard implementation that can outperform a Standard counterpart in terms of execution time and/or memory consumption. Can we find a superior alternative to the most commonly used collection types? 2
20 Experimental Study on Java Collections We selected 6 alternative libraries: Repository Popularity (GitHub) Appearance in previous partial benchmarks Libraries Version JCF Compatible Available at Trove.0. yes trove.starlight-systems.com Guava 8.0 yes /google/guava GSCollections yes /goldmansachs/gs-collections HPPC 0.7. no github /carrotsearch/hppc Fastutil yes /vigna/fastutil Koloboke yes /leventov/koloboke
21 Experimental Study on Java Collections Seven typical scenarios evaluated populate, iterate, contains, get, add, remove, copy Collections holding from 00 to million elements Alternatives to the most commonly used collections JDK.8.0_65 ArrayList, HashMap, HashSet and LinkedList Object collection alternatives Primitive collection alternatives 4
22 CollectionsBench Suite We create a benchmark suite: CollectionsBench Open Java Microbenchmark public void setup() { fulllist = this.createnewlist(); fulllist.addall(values); // Randomly } public void iterate() { for (T element : fulllist) { blackhole.consume(element); // Blackholes avoid dead-code // optimization } } 5
23 CollectionsBench Suite We create a benchmark suite: public void setup() { fulllist = this.createnewlist(); fulllist.addall(values); // Randomly } public void iterate() { for (T element : fulllist) { blackhole.consume(element); // Blackholes avoid dead-code // optimization } Only the instantiation is needed for each collection type* return new ArrayList<T>(); return new LinkedList<T>(); return new FastList<T>(); Here we measure: Execution time (ns) Collection Overhead (allocation) GC Profiler } 6
24 Experimental Planning To accomplish a steady state performance public void iterate() 5s Iteration 7
25 Experimental Planning To accomplish a steady state performance evaluation: public void iterate() Warmup 0x Iteration 5s Measured 0x Iteration Iteration 7
26 Experimental Planning To accomplish a steady state performance evaluation: Fork Fork public void iterate() Warmup 0x Iteration 0x Iteration 5s Measured 0x Iteration 0x Iteration Iteration 7
27 Experimental Planning To accomplish a steady state performance evaluation: Fork Fork public void iterate() Warmup 0x Iteration 0x Iteration 5s Measured 0x Iteration 0x Iteration Iteration AVG Time ± CI (99%) AVG Memory allocated ± CI (99%) 7
28 Reporting Speedup/Slowdown We present the results of alternatives normalized to the Standard implementation performances. Means with overlapping CI are set to zero We use the following speedup/slowdown definitions: S = T std T alt, if T std > T alt T alt T std, otherwise 8
29 2 2 Reporting Speedup/Slowdown We present the results of alternatives normalized to the Standard implementation performances. Means with overlapping CI are set to zero We use the following speedup/slowdown definitions: S = T std T alt, if T std > T alt T alt T std, otherwise S = {0,.5,.9, 2, 7.8} S = {0,.5,.9, 2, 7.8} Heat map 7 7 Overlapping Confidence Intervals 9
30 Reporting Memory Overhead For the memory comparison we present the collection overhead reduction per element (with compressed object pointers) 20
31 Reporting Memory Overhead For the memory comparison we present the collection overhead reduction per element (with compressed object pointers) For instance Collection X: 00 bytes per element Collection Y: 0 bytes per element Evaluated on the copy scenario 20
32 Reporting Memory Overhead For the memory comparison we present the collection overhead reduction per element (with compressed object pointers) For instance Collection X: 00 bytes per element Collection Y: 0 bytes per element Evaluated on the copy scenario 90% Reduction of Collection Overhead 20
33 * * * * Superior Alternatives: LinkedList LinkedList was outperformed by every ArrayList alternative JCF LinkedList$Entry consumes 24 bytes Standard JCF FU 2 Fastutil 2 GSCollec. 2 HPPC 2 2 contains add get remove copy * * * * * * * * * * * * * * * * 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 84% Reduction of Collection Overhead 2
34 * * * * Superior Alternatives: LinkedList LinkedList was outperformed by every ArrayList alternative JCF LinkedList$Entry consumes 24 bytes Standard JCF FU 2 Fastutil 2 GSCollec. 2 HPPC 2 2 contains add get remove copy * * * * * * * * * * * * * * * * 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M Asymptotic disadvantage 84% Reduction of Collection Overhead 2
35 * * * * Superior Alternatives: LinkedList LinkedList was outperformed by every ArrayList alternative JCF LinkedList$Entry consumes 24 bytes Standard JCF FU 2 Fastutil 2 GSCollec. 2 HPPC 2 2 contains add get remove copy * * * * * * * * * * * * * * * * 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M Asymptotic disadvantage Asymptotic advantage public boolean remove(object o) 84% Reduction of Collection Overhead 2
36 Superior Alternatives: ArrayList GSCollections provides a superior alternative Faster when populating the list (no time penalty) Fastutil FU GSCollec. HPPC populate iterate copy K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M No memory difference 22
37 Superior Alternatives: ArrayList GSCollections provides a superior alternative Faster when populating the list (no time penalty) Fastutil FU GSCollec. HPPC populate iterate copy K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M No memory difference Distinct Array copy calls Std: Arrays.copyOf(); Alt: System.arraycopy(); 22
38 Superior Alternatives: ArrayList GSCollections provides a superior alternative Faster when populating the list (no time penalty) Fastutil FU GSCollec. HPPC populate iterate copy K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M No memory difference Distinct Array copy calls Std: Arrays.copyOf(); Alt: System.arraycopy(); HPPC adds each element instead of copying the array 22
39 Superior Alternatives: HashSet Koloboke provides a superior alternative Fastutil is a solid 2 nd option Std HashSet$Node object consumes 2 bytes Fastutil FU 0 GSCollec. - Guava 0 HPPC Koloboke 0 Trove HP -2 Tr -2 populate iterate contains add remove copy 00 K 0K 00K M 00 K 0K 00 K M 00 K 0K 00 K M 00 K 0K 00 K M 00 K 0K 00 K M 00 K 0K 00 K M 75% Reduction of Collection Overhead 2
40 Superior Alternatives: HashSet Koloboke provides a superior alternative Fastutil is a solid 2 nd option Std HashSet$Node object consumes 2 bytes Fastutil FU 0 GSCollec. - Guava 0 HPPC Koloboke 0 Trove HP -2 Tr -2 populate iterate contains add remove copy 00 K 0K 00K M 00 K 0K 00 K M 00 K 0K 00 K M 00 K 0K 00 K M 00 K 0K 00 K M 00 K 0K 00 K M 75% Reduction of Collection Overhead Impact of memory efficiency on time Koloboke performs a memory copy of its HashTable 2
41 Superior Alternatives: HashMap Standard HashMap is a solid implementation No superior alternatives on time populate iterate contains remove copy Fastutil FU 0 GSCollec. - Guava HPPC Koloboke Trove HP -2 Ko K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M -2 24
42 Superior Alternatives: HashMap Standard HashMap is a solid implementation No superior alternatives on time Fastutil provides a superior alternative on memory consumption populate iterate contains remove copy Fastutil FU 0 GSCollec. - Guava HPPC Koloboke Trove HP -2 Ko K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M -2 55% Reduction of Collection Overhead Std. HashMap$Node object consumes 2 bytes 24
43 Object vs Primitive Collections Reducing collection footprint: overhead + element footprint Object collection ArrayList<> Primitive collection IntArrayList Object[] int[] 25
44 Object vs Primitive Collections Reducing collection footprint: overhead + element footprint Object collection ArrayList<> Smaller Collection Overhead Primitive collection IntArrayList Object[] int[] 25
45 Object vs Primitive Collections Reducing collection footprint: overhead + element footprint Object collection ArrayList<> Smaller Collection Overhead Primitive collection IntArrayList Object[] int[] Integer (6 bytes) int (4 bytes) 25
46 Object vs Primitive Collections Reducing collection footprint: overhead + element footprint Object collection ArrayList<> Smaller Collection Overhead Primitive collection IntArrayList Smaller Element Footprint Object[] int[] Integer (6 bytes) int (4 bytes) 25
47 Object vs Primitive Collections Reducing collection footprint: overhead + element footprint Object collection ArrayList<> Smaller Collection Overhead Primitive collection IntArrayList Smaller Element Footprint Object[] int[] Integer (6 bytes) int (4 bytes) 25
48 Object vs Primitive Collections Reducing collection footprint: overhead + element footprint Object collection ArrayList<> Primitive collection IntArrayList Smaller Collection Overhead Collection Footprint Reduction Smaller Element Footprint 80% Object[] int[] Integer (6 bytes) int (4 bytes) 25
49 Superior Alternatives: Primitive Collections We found superior alternatives to all three abstraction types Data Type: Integer to int Performance varies considerably from distinct libraries for multiple reasons For instance, ArrayList primitive implementations Fastutil GSCollec. HPPC Trove Libs populate iterate contains copy FU GS 4 HP Tr K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 26
50 Superior Alternatives: Primitive Collections We found superior alternatives to all three abstraction types Data Type: Integer to int Performance varies considerably from distinct libraries for multiple reasons For instance, ArrayList primitive implementations Fastutil GSCollec. HPPC Trove Libs populate iterate contains copy FU GS 4 HP Tr K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M for(object..) 5x slower than for(intprocedure) commonly implemented 26
51 Superior Alternatives: Primitive Collections We found superior alternatives to all three abstraction types Data Type: Integer to int Performance varies considerably from distinct libraries for multiple reasons For instance, ArrayList primitive implementations Fastutil GSCollec. HPPC Trove Libs populate iterate contains copy FU GS 4 HP Tr K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M 00 K 0K 00K M for(object..) 5x slower than for(intprocedure) commonly implemented 0% more branch misses for (int = offset; i-- > 0; ) 26
52 Superior Alternative: Primitive Collections GSCollections, Koloboke and Fastutil provide solid superior alternatives ArrayList HashMap HashSet Footprint Reduction Integer int 80% 76% 84% Time impact (M elements) +2x populate +4x contains 2x +2x remove +2x populate -2x iterate 2x +6x/+4x copy +4x populate +4x/+x iterate 2x +x/+7x copy 27
53 Summary There are performance opportunities on Alternative Collection Frameworks Time/memory improvement with moderate refactor effort We provide a Guideline to assist developers on: Identifying superior alternative implementations Which scenarios an alternative could lead to a substantial performance improvement CollectionsBench is open-source and available at GitLab 28
54 Thank you for your time Questions? 29
Building Memory-efficient Java Applications: Practices and Challenges
Building Memory-efficient Java Applications: Practices and Challenges Nick Mitchell, Gary Sevitsky (presenting) IBM TJ Watson Research Center Hawthorne, NY USA Copyright is held by the author/owner(s).
More informationInterfaces and Collections
Interfaces and Collections COMPSCI 2S03 Mikhail Andrenkov Department of Computing and Software McMaster University Week 9: November 14-18 Mikhail Andrenkov Interfaces and Collections 1 / 25 Outline 1 Interfaces
More informationTECHNICAL WHITEPAPER. Performance Evaluation Java Collections Framework. Performance Evaluation Java Collections. Technical Whitepaper.
Performance Evaluation Java Collections Framework TECHNICAL WHITEPAPER Author: Kapil Viren Ahuja Date: October 17, 2008 Table of Contents 1 Introduction...3 1.1 Scope of this document...3 1.2 Intended
More informationFrom Java Code to Java Heap Understanding the Memory Usage of Your Application
Chris Bailey IBM Java Service Architect 3 rd October 2012 From Java Code to Java Heap Understanding the Memory Usage of Your Application 2012 IBM Corporation Important Disclaimers THE INFORMATION CONTAINED
More informationCONTAİNERS COLLECTİONS
CONTAİNERS Some programs create too many objects and deal with them. In such a program, it is not feasible to declare a separate variable to hold reference to each of these objects. The proper way of keeping
More informationEXAMINATIONS 2011 Trimester 2, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2011 Trimester 2, MID-TERM TEST COMP103 Introduction
More informationJava Collections Framework reloaded
Java Collections Framework reloaded October 1, 2004 Java Collections - 2004-10-01 p. 1/23 Outline Interfaces Implementations Ordering Java 1.5 Java Collections - 2004-10-01 p. 2/23 Components Interfaces:
More informationJava Collections Framework
Java Collections Framework Introduction In this article from my free Java 8 course, you will be given a high-level introduction of the Java Collections Framework (JCF). The term Collection has several
More informationABSTRACT DATA TYPES: COLLECTIONS, LISTS, SETS, MAP, QUEUES. Thursday, June 30, 2011
1 ABSTRACT DATA TYPES: COLLECTIONS, LISTS, SETS, MAP, QUEUES Lecture 4 CS 2110 Summer 2011 Lists are Iterable 4 for public static void printlist(list strings) { for (int idx = 0; idx < strings.size();
More informationCollections. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff
Collections by Vlad Costel Ungureanu for Learn Stuff Collections 2 Collections Operations Add objects to the collection Remove objects from the collection Find out if an object (or group of objects) is
More informationEffec%ve So*ware. Lecture 9: JVM - Memory Analysis, Data Structures, Object Alloca=on. David Šišlák
Effec%ve So*ware Lecture 9: JVM - Memory Analysis, Data Structures, Object Alloca=on David Šišlák david.sislak@fel.cvut.cz JVM Performance Factors and Memory Analysis» applica=on performance factors total
More informationJava Collections The Force Awakens.
Java Collections The Force Awakens Darth @RaoulUK Darth @RichardWarburto Collection Problems Java Episode 8 & 9 Persistent & Immutable Collections HashMaps Collection bugs 1. 2. 3. Element access (Off-by-one
More informationCollections (Java) Collections Framework
Collections (Java) https://docs.oracle.com/javase/tutorial/collections/index.html Collection an object that groups multiple elements into a single unit. o store o retrieve o manipulate o communicate o
More informationProgrammieren II. Polymorphism. Alexander Fraser. June 4, (Based on material from T. Bögel)
Programmieren II Polymorphism Alexander Fraser fraser@cl.uni-heidelberg.de (Based on material from T. Bögel) June 4, 2014 1 / 50 Outline 1 Recap - Collections 2 Advanced OOP: Polymorphism Polymorphism
More informationToday's Agenda. > To give a practical introduction to data structures. > To look specifically at Lists, Sets, and Maps
Today's Agenda > To give a practical introduction to data structures > To look specifically at Lists, Sets, and Maps > To talk briefly about Generics in Java > To talk about interfaces in Java Data Structures
More informationFundamental language mechanisms
Java Fundamentals Fundamental language mechanisms The exception mechanism What are exceptions? Exceptions are exceptional events in the execution of a program Depending on how grave the event is, the program
More informationAdvanced Programming Languages Effective Java Item 1. Spring 2015 Chungnam National Univ Eun-Sun Cho
Advanced Programming Languages Effective Java Item 1 Spring 2015 Chungnam National Univ Eun-Sun Cho 1 1. Introduction 2. Creating and Destroying Objects Item 1: Consider static factory methods instead
More informationImplementation. Learn how to implement the List interface Understand the efficiency trade-offs between the ArrayList and LinkedList implementations
Readings List Implementations Chapter 20.2 Objectives Learn how to implement the List interface Understand the efficiency trade-offs between the ArrayList and LinkedList implementations Additional references:
More informationComputational Expression
Computational Expression ArrayList Iterators Janyl Jumadinova 7-14 November, 2018 Janyl Jumadinova Computational Expression 7-14 November, 2018 1 / 11 Collections Collection: an object that stores data;
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationEnergy Profiles of Java Collections Classes
Energy Profiles of Java Collections Classes Samir Hasan Computer Science and Software Engineering Auburn University szh64@auburn.edu Mohammed Sayagh MCIS Polytechnique Montreal mohammed.sayagh@polymtl.ca
More informationIntroduction to Computer Science I
Introduction to Computer Science I Iterators ArrayList Janyl Jumadinova October 31, 2016 Iterators One of the most useful operations for any collection is the ability to run through each of the elements
More informationProgrammieren II. Collections. Alexander Fraser. May 28, (Based on material from T. Bögel)
Programmieren II Collections Alexander Fraser fraser@cl.uni-heidelberg.de (Based on material from T. Bögel) May 28, 2014 1 / 46 Outline 1 Recap Paths and Files Exceptions 2 Collections Collection Interfaces
More informationAlgorithms. Produced by. Eamonn de Leastar
Algorithms Produced by Eamonn de Leastar (edeleastar@wit.ie) Collections ± Collections Architecture ± Definition ± Architecture ± Interfaces ± Collection ± List ± Set ± Map ± Iterator ± Implementations
More informationModel Solutions. COMP 103: Test April, 2013
Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 40 minutes
More information27/04/2012. Objectives. Collection. Collections Framework. "Collection" Interface. Collection algorithm. Legacy collection
Objectives Collection Collections Framework Concrete collections Collection algorithm By Võ Văn Hải Faculty of Information Technologies Summer 2012 Legacy collection 1 2 2/27 Collections Framework "Collection"
More informationUnit5: Packages and abstraction. Prepared by: Dr. Abdallah Mohamed, AOU-KW Updated by Mrs. Malak EL-Amir AOU SAB Fall 14-15
Unit5: Packages and abstraction Prepared by: Dr. Abdallah Mohamed, AOU-KW Updated by Mrs. Malak EL-Amir AOU SAB Fall 14-15 1 1. Introduction 2. Java libraries 3. The documentation of standard packages
More informationModel Solutions. COMP 103: Test May, 2013
Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 45 minutes
More informationWhat is the Java Collections Framework?
1 of 13 What is the Java Collections Framework? To begin with, what is a collection?. I have a collection of comic books. In that collection, I have Tarzan comics, Phantom comics, Superman comics and several
More information5/23/2015. Core Java Syllabus. VikRam ShaRma
5/23/2015 Core Java Syllabus VikRam ShaRma Basic Concepts of Core Java 1 Introduction to Java 1.1 Need of java i.e. History 1.2 What is java? 1.3 Java Buzzwords 1.4 JDK JRE JVM JIT - Java Compiler 1.5
More informationCollections Framework: Part 2
Collections Framework: Part 2 Computer Science and Engineering College of Engineering The Ohio State University Lecture 18 Collection Implementations Java SDK provides several implementations of Collection
More informationBuilding Java Programs
Building Java Programs Chapter 16 References and linked nodes reading: 16.1 2 Value semantics value semantics: Behavior where values are copied when assigned, passed as parameters, or returned. All primitive
More informationEfficient Java (with Stratosphere) Arvid Heise, Large Scale Duplicate Detection
Efficient Java (with Stratosphere) Arvid Heise, Large Scale Duplicate Detection Agenda 2 Bottlenecks Mutable vs. Immutable Caching/Pooling Strings Primitives Final Classloaders Exception Handling Concurrency
More informationEXAMINATIONS 2017 TRIMESTER 2
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2017 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS
More informationComputer Science II (Spring )
Computer Science II 4003-232-01 (Spring 2007-2008) Week 5: Generics, Java Collection Framework Richard Zanibbi Rochester Institute of Technology Generic Types in Java (Ch. 21 in Liang) What are Generic
More informationCS Programming Language Java. Fall 2004 Sept. 29
CS3101-3 Programming Language Java Fall 2004 Sept. 29 Road Map today Java review Homework review Exception revisited Containers I/O What is Java A programming language A virtual machine JVM A runtime environment
More informationCore Java Contents. Duration: 25 Hours (1 Month)
Duration: 25 Hours (1 Month) Core Java Contents Java Introduction Java Versions Java Features Downloading and Installing Java Setup Java Environment Developing a Java Application at command prompt Java
More informationWentworth Institute of Technology COMP1050 Computer Science II Spring 2017 Derbinsky. Collections & Maps. Lecture 12. Collections & Maps
Lecture 12 1 Review: Data Structure A data structure is a collection of data organized in some fashion The structure not only stores data but also supports operations for accessing/manipulating the data
More informationCollections Questions
Collections Questions https://www.journaldev.com/1330/java-collections-interview-questions-and-answers https://www.baeldung.com/java-collections-interview-questions https://www.javatpoint.com/java-collections-interview-questions
More information40) Class can be inherited and instantiated with the package 41) Can be accessible anywhere in the package and only up to sub classes outside the
Answers 1) B 2) C 3) A 4) D 5) Non-static members 6) Static members 7) Default 8) abstract 9) Local variables 10) Data type default value 11) Data type default value 12) No 13) No 14) Yes 15) No 16) No
More informationCopyright 2012, Oracle and/or its affiliates. All rights reserved.
1 Field guide to Java collections Mike Duigou (@mjduigou) Java Core Libraries 2 Required Reading Should have used most at some point List, Vector, ArrayList, LinkedList, Arrays.asList Set, HashSet, TreeSet
More informationAdvanced Programming Generics Collections
Advanced Programming Generics Collections The Context Create a data structure that stores elements: a stack, a linked list, a vector a graph, a tree, etc. What data type to use for representing the elements
More informationCore Java Syllabus. Overview
Core Java Syllabus Overview Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java
More informationCS2113 Lab: Collections 10/29/2018
CS2113 Lab: Collections Yawei Wang 10/29/2018 Install and Use IntelliJ on Mac or Window If you haven t installed JDK before, go to https://www.oracle.com/technetwork/java/javaseproducts/downloads/in dex.html
More informationFamily Name:... Other Names:... ID Number:... Signature... Model Solutions. COMP 103: Test 1. 9th August, 2013
Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Model Solutions COMP 103: Test
More informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:
More information11-1. Collections. CSE 143 Java. Java 2 Collection Interfaces. Goals for Next Several Lectures
Collections CSE 143 Java Collections Most programs need to store and access collections of data Collections are worth studying because... They are widely useful in programming They provide examples of
More informationModel Solutions. COMP 103: Mid-term Test. 19th of August, 2016
Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 45 minutes
More informationEXAMINATIONS 2012 Trimester 1, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2012 Trimester 1, MID-TERM TEST COMP103 Introduction
More informationEXAMINATIONS 2015 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS
T E W H A R E W Ā N A N G A O T E Student ID:....................... Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2015 TRIMESTER 2 COMP103 INTRODUCTION
More informationCMSC 202. Containers
CMSC 202 Containers Container Definition A container is a data structure whose purpose is to hold objects. Most languages support several ways to hold objects. Arrays are compiler-supported containers.
More informationA Comprehensive Study on the Energy Efficiency of Java Thread-Safe Collections. Fernando Castor
A Comprehensive Study on the Energy Efficiency of Java Thread-Safe Collections Gustavo Pinto Kenan Liu Fernando Castor David Liu 1 Disclaimer 2 Miguel turns 8mo today! 3 Motivations 4 First, energy consumption
More informationPieter van den Hombergh Richard van den Ham. February 8, 2018
Pieter van den Hombergh Richard van den Ham Fontys Hogeschool voor Techniek en Logistiek February 8, 2018 /FHTenL February 8, 2018 1/16 Collection Zoo The basic collections, well known in programming s
More informationJava Magistère BFA
Java 101 - Magistère BFA Lesson 4: Generic Type and Collections Stéphane Airiau Université Paris-Dauphine Lesson 4: Generic Type and Collections (Stéphane Airiau) Java 1 Linked List 1 public class Node
More informationJAVA. Duration: 2 Months
JAVA Introduction to JAVA History of Java Working of Java Features of Java Download and install JDK JDK tools- javac, java, appletviewer Set path and how to run Java Program in Command Prompt JVM Byte
More informationPieter van den Hombergh Thijs Dorssers Stefan Sobek. June 8, 2017
Pieter van den Hombergh Thijs Dorssers Stefan Sobek Fontys Hogeschool voor Techniek en Logistiek June 8, 2017 /FHTenL June 8, 2017 1/19 Collection Zoo The basic collections, well known in programming s
More informationGet started with the Java Collections Framework By Dan Becker
Get started with the Java Collections Framework By Dan Becker JavaWorld Nov 1, 1998 COMMENTS JDK 1.2 introduces a new framework for collections of objects, called the Java Collections Framework. "Oh no,"
More informationJava Data Structures Collections Framework BY ASIF AHMED CSI-211 (OBJECT ORIENTED PROGRAMMING)
Java Data Structures Collections Framework BY ASIF AHMED CSI-211 (OBJECT ORIENTED PROGRAMMING) What is a Data Structure? Introduction A data structure is a particular way of organizing data using one or
More information36. Collections. Java. Summer 2008 Instructor: Dr. Masoud Yaghini
36. Collections Java Summer 2008 Instructor: Dr. Masoud Yaghini Outline Introduction Arrays Class Interface Collection and Class Collections ArrayList Class Generics LinkedList Class Collections Algorithms
More informationEXAMINATIONS 2016 TRIMESTER 2
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2016 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS
More informationExamination Questions Midterm 1
CS1102s Data Structures and Algorithms 10/2/2010 Examination Questions Midterm 1 This examination question booklet has 9 pages, including this cover page, and contains 15 questions. You have 40 minutes
More informationJAVA SYLLABUS FOR 6 WEEKS
JAVA SYLLABUS FOR 6 WEEKS Java 6-Weeks INTRODUCTION TO JAVA History and Features of Java Comparison of C, C++, and Java Java Versions and its domain areas Life cycle of Java program Writing first Java
More informationToday: Java Library Classes for lists. Iterators, ListIterators. CS61B Lecture #7. Last modified: Fri Sep 12 14:41: CS61B: Lecture #7 1
Today: Java Library Classes for lists. Iterators, ListIterators CS61B Lecture #7 Last modified: Fri Sep 12 14:41:31 2008 CS61B: Lecture #7 1 Abstracting Listness So far, we ve seen fairly primitive types
More informationStrings and Arrays. Hendrik Speleers
Hendrik Speleers Overview Characters and strings String manipulation Formatting output Arrays One-dimensional Two-dimensional Container classes List: ArrayList and LinkedList Iterating over a list Characters
More informationThe Collections API. Lecture Objectives. The Collections API. Mark Allen Weiss
The Collections API Mark Allen Weiss Lecture Objectives To learn how to use the Collections package in Java 1.2. To illustrate features of Java that help (and hurt) the design of the Collections API. Tuesday,
More informationNAME: c. (true or false) The median is always stored at the root of a binary search tree.
EE 322C Spring 2009 (Chase) Exam 2: READ THIS FIRST. Please use the back side of each page for scratch paper. For some of the questions you may need to think quite a bit before you write down an answer.
More informationCMSC 202H. Containers and Iterators
CMSC 202H Containers and Iterators Container Definition A container is a data structure whose purpose is to hold objects. Most languages support several ways to hold objects Arrays are compiler-supported
More informationJAVA 2 ENTERPRISE EDITION (J2EE)
COURSE TITLE DETAILED SYLLABUS SR.NO JAVA 2 ENTERPRISE EDITION (J2EE) ADVANCE JAVA NAME OF CHAPTERS & DETAILS HOURS ALLOTTED SECTION (A) BASIC OF J2EE 1 FILE HANDLING Stream Reading and Creating file FileOutputStream,
More informationObject-Oriented Programming with Java
Object-Oriented Programming with Java Recitation No. 2 Oranit Dror The String Class Represents a character string (e.g. "Hi") Explicit constructor: String quote = "Hello World"; string literal All string
More informationJava Collections. Readings and References. Collections Framework. Java 2 Collections. CSE 403, Spring 2004 Software Engineering
Readings and References Java Collections "Collections", Java tutorial http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Spring 2004 Software Engineering http://www.cs.washington.edu/education/courses/403/04sp/
More informationCOMP103 Test. 5 Sept, 2007
Family Name:.......................... Other Names:.......................... ID Number:............................ COMP103 Test 5 Sept, 2007 Instructions Time: 90 minutes. Answer all the questions. There
More informationCS2110: Software Development Methods. Maps and Sets in Java
CS2110: Software Development Methods Maps and Sets in Java These slides are to help with the lab, Finding Your Way with Maps Today s lab uses Maps (and Sets but just a little). Readings from textbook:
More informationBuilding Java Programs
Building Java Programs Chapter 16 References and linked nodes reading: 16.1 2 Recall: stacks and queues stack: retrieves elements in reverse order as added queue: retrieves elements in same order as added
More informationRecommending Energy-Efficient Java Collections
Recommending Energy-Efficient Java Collections Wellington Oliveira, Renato Oliveira, Fernando Castor, Benito Fernandes, Gustavo Pinto Federal University of Pernambuco {woj, ros3, jbfan, castor}@cin.ufpe.br
More informationRecap. List Types. List Functionality. ListIterator. Adapter Design Pattern. Department of Computer Science 1
COMP209 Object Oriented Programming Container Classes 3 Mark Hall List Functionality Types List Iterator Adapter design pattern Adapting a LinkedList to a Stack/Queue Map Functionality Hashing Performance
More informationAP Computer Science 4325
4325 Instructional Unit Algorithm Design Techniques -divide-and-conquer The students will be -Decide whether an algorithm -classroom discussion -backtracking able to classify uses divide-and-conquer, -worksheets
More informationCIS 265 Exam 2 First Name Last Name
CIS 265 Exam 2 First Name Last Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Which of the data types below does not allow duplicates? 1)
More informationData Structures and Algorithms in Java. Second Year Software Engineering
Data Structures and Algorithms in Java Second Year Software Engineering Introduction Computer: is a programmable machine that can store, retrieve and process data. Data: The representation of information
More informationC06: Java API & Libraries
CISC 3120 C06: Java API & Libraries Hui Chen Department of Computer & Information Science CUNY Brooklyn College 2/20/2018 CUNY Brooklyn College 1 Outline Recap and issues Grades and feedback Java classes
More informationCS11 Java. Winter Lecture 8
CS11 Java Winter 2010-2011 Lecture 8 Java Collections Very powerful set of classes for managing collections of objects Introduced in Java 1.2 Provides: Interfaces specifying different kinds of collections
More informationModel Solutions. COMP 103: Mid-term Test. 21st of August, 2014
Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 50 minutes
More informationAssoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Up to here Not included in program Java collections framework prebuilt data structures interfaces and methods for manipulating
More informationPeers Techno log ies Pv t. L td. Core Java & Core Java &Adv Adv Java Java
Page 1 Peers Techno log ies Pv t. L td. Course Brochure Core Java & Core Java &Adv Adv Java Java Overview Core Java training course is intended for students without an extensive programming background.
More informationAn Interface with Generics
Generics CSC207 Software Design Generics An Interface with Generics Generics class foo introduces a class with a type parameter T. introduces a type parameter that is required to be
More information182 review 1. Course Goals
Course Goals 182 review 1 More experience solving problems w/ algorithms and programs minimize static methods use: main( ) use and overload constructors multiple class designs and programming solutions
More informationJava Collections Framework. 24 April 2013 OSU CSE 1
Java Collections Framework 24 April 2013 OSU CSE 1 Overview The Java Collections Framework (JCF) is a group of interfaces and classes similar to the OSU CSE components The similarities will become clearly
More information1B1a Arrays. Arrays. Indexing. Naming arrays. Why? Using indexing. 1B1a Lecture Slides. Copyright 2003, Graham Roberts 1
Ba Arrays Arrays A normal variable holds value: An array variable holds a collection of values: 4 Naming arrays An array has a single name, so the elements are numbered or indexed. 0 3 4 5 Numbering starts
More informationPhase-based Adaptive Recompilation in a JVM
Phase-based Adaptive Recompilation in a JVM Dayong Gu Clark Verbrugge Sable Research Group, School of Computer Science McGill University, Montréal, Canada {dgu1, clump}@cs.mcgill.ca April 7, 2008 Sable
More informationSoftware Practice 1 - OOP (3) API
Software Practice 1 - OOP (3) API Access Control Review Packages Java API Documentation Prof. Joonwon Lee T.A. Jaehyun Song Jongseok Kim (42) T.A. Sujin Oh Junseong Lee (43) 1 / 41 2 / 41 ACCESS CONTROL
More informationPerchance to Stream with Java 8
Perchance to Stream with Java 8 Paul Sandoz Oracle The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated $$ into
More informationCS2110: Software Development Methods. Maps and Sets in Java
CS2110: Software Development Methods Maps and Sets in Java These slides are to help with the lab, Finding Your Way with Maps This lab uses Maps, and Sets too (but just a little). Readings from textbook:
More informationCOSC 123 Computer Creativity. Java Lists and Arrays. Dr. Ramon Lawrence University of British Columbia Okanagan
COSC 123 Computer Creativity Java Lists and Arrays Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Objectives 1) Create and use arrays of base types and objects. 2) Create
More informationCITS1001 week 6 Libraries
CITS1001 week 6 Libraries Arran Stewart April 12, 2018 1 / 52 Announcements Project 1 available mid-semester test self-assessment 2 / 52 Outline Using library classes to implement some more advanced functionality
More informationSEEDS: A Software Engineer s Energy-optimization Decision Support Framework
SEEDS: A Software Engineer s Energy-optimization Decision Support Framework Irene Manotas Computer Science University of Delaware Newark, DE 19716 imanotas@udel.edu Lori Pollock Computer Science University
More informationChapter 10 Collections
Chapter 10 Collections I. Scott MacKenzie 1 Outline 2 1 What is a Collection? A collection is an aggregation with a variable number of components, or elements Examples Portfolio - a collection of Investment
More informationParsing JSON, Using Libraries, Java Collections, Generics. Slides adapted from Craig Zilles
Parsing JSON, Using Libraries, Java Collections, Generics Slides adapted from Craig Zilles 1 CamelCaser Difficulty How difficult was the first assignment? A. Easy B. Moderate C. Challenging D. Unreasonable
More informationFirst Name Last Name ID#
CIS 265 Sect 01 - V. Matos Exam-2 Spring-2015 First Name Last Name ID# (15 pts) MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) In the following
More informationIntroduction to Collections
Module 3 COLLECTIONS Introduction to Collections > A collection sometimes called a container is simply an object that groups multiple elements into a single unit. > Collections are used to store, retrieve,
More information17. Java Collections. Organizing Data. Generic List in Java: java.util.list. Type Parameters ( Parameteric Polymorphism ) Data Structures that we know
Organizing Data Data Structures that we know 17 Java Collections Generic Types, Iterators, Java Collections, Iterators Today: Arrays Fixed-size sequences Strings Sequences of characters Linked Lists (up
More informationCore Java SYLLABUS COVERAGE SYLLABUS IN DETAILS
Core Java SYLLABUS COVERAGE Introduction. OOPS Package Exception Handling. Multithreading Applet, AWT, Event Handling Using NetBean, Ecllipse. Input Output Streams, Serialization Networking Collection
More information