The document discusses the Java Collection Framework, which provides classes and interfaces for storing and manipulating groups of objects. It describes key interfaces like Collection, List, Set, and Map. Implementation classes are covered, including ArrayList, LinkedList, HashSet, TreeSet, and PriorityQueue. The document outlines how iterators can be used to access elements within a collection.
The Java Collections Framework provides classes and interfaces that help store and manipulate collections of objects. The main collection interfaces are List, Set, and Map. Lists allow duplicate elements and access by index. Common List implementations are ArrayList and LinkedList. Sets do not allow duplicates. Common Set implementations are HashSet, LinkedHashSet, and TreeSet. Maps store objects in key-value pairs and cannot have duplicate keys. Common Map implementations are HashMap, TreeMap, and LinkedHashMap.
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Edureka!
**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****
This Edureka tutorial on “Java Collections” will talk about the complete hierarchy of Collections Frameworks in Java. It will walk you through the various fundamentals of collections like Lists, Queue, Sets, Interfaces etc. Through this tutorial you will learn the following topics:
Java Collection Framework
Collection Framework Hierarchy
Interfaces
List
Queue
Set
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/gMFLx3
To learn important concept of Collection and its handling plus its advantages and different class & child class of Collection and their implementations. Important interview questions of the collection.
This document provides an overview of Java's collections framework. It discusses the main interfaces like Collection, Set, List, and Map. It also describes some common implementations like ArrayList, LinkedList, HashSet, TreeMap. The key characteristics of lists, sets, and maps are explained. Lists maintain element order and allow duplicates. Sets do not allow duplicates. Maps contain unique keys that map to values. The document also covers common collection operations and using iterators to traverse elements.
The document discusses collection framework in Java. It explains that arrays have fixed size and hold homogeneous elements while collections are growable and can hold heterogeneous elements. The key interfaces and classes of collection framework include Collection, List, Set, Queue, and Map. Common implementations like ArrayList, LinkedList, Vector, Stack are also covered along with their properties and usage. Cursors like Enumeration, Iterator and ListIterator are explained which can be used to traverse collection elements.
This document provides an overview of Java collection classes and interfaces. It discusses the Collection framework, commonly used methods for Collection, List, Iterator, ArrayList, LinkedList, Set, Queue, Map, Entry, and sorting. The key classes covered are Collection, List, Iterator, ArrayList, LinkedList, HashSet, Queue, Map, and Entry. It explains the purpose of each interface and differences between data structures like ArrayList vs LinkedList, List vs Set.
Collections Framework is a unified architecture for managing collections, Main Parts of Collections Framework
1. Interfaces :- Core interfaces defining common functionality exhibited by collections
2. Implementations :- Concrete classes of the core interfaces providing data structures
3. Operations :- Methods that perform various operations on collections
The document discusses Java collections and the Google Collections library. It provides an overview of common collection interfaces like List, Set, Queue and Map in Java and their implementations. It also describes additional collection types and utilities provided by the Google Collections library, such as Multimap, Multiset, BiMap, Immutable collections and functional programming utilities like Predicates and Functions.
The Java Collections Framework provides classes and interfaces that help store and manipulate collections of objects. The main collection interfaces are List, Set, and Map. Lists allow duplicate elements and access by index. Common List implementations are ArrayList and LinkedList. Sets do not allow duplicates. Common Set implementations are HashSet, LinkedHashSet, and TreeSet. Maps store objects in key-value pairs and cannot have duplicate keys. Common Map implementations are HashMap, TreeMap, and LinkedHashMap.
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Edureka!
**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****
This Edureka tutorial on “Java Collections” will talk about the complete hierarchy of Collections Frameworks in Java. It will walk you through the various fundamentals of collections like Lists, Queue, Sets, Interfaces etc. Through this tutorial you will learn the following topics:
Java Collection Framework
Collection Framework Hierarchy
Interfaces
List
Queue
Set
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/gMFLx3
To learn important concept of Collection and its handling plus its advantages and different class & child class of Collection and their implementations. Important interview questions of the collection.
This document provides an overview of Java's collections framework. It discusses the main interfaces like Collection, Set, List, and Map. It also describes some common implementations like ArrayList, LinkedList, HashSet, TreeMap. The key characteristics of lists, sets, and maps are explained. Lists maintain element order and allow duplicates. Sets do not allow duplicates. Maps contain unique keys that map to values. The document also covers common collection operations and using iterators to traverse elements.
The document discusses collection framework in Java. It explains that arrays have fixed size and hold homogeneous elements while collections are growable and can hold heterogeneous elements. The key interfaces and classes of collection framework include Collection, List, Set, Queue, and Map. Common implementations like ArrayList, LinkedList, Vector, Stack are also covered along with their properties and usage. Cursors like Enumeration, Iterator and ListIterator are explained which can be used to traverse collection elements.
This document provides an overview of Java collection classes and interfaces. It discusses the Collection framework, commonly used methods for Collection, List, Iterator, ArrayList, LinkedList, Set, Queue, Map, Entry, and sorting. The key classes covered are Collection, List, Iterator, ArrayList, LinkedList, HashSet, Queue, Map, and Entry. It explains the purpose of each interface and differences between data structures like ArrayList vs LinkedList, List vs Set.
Collections Framework is a unified architecture for managing collections, Main Parts of Collections Framework
1. Interfaces :- Core interfaces defining common functionality exhibited by collections
2. Implementations :- Concrete classes of the core interfaces providing data structures
3. Operations :- Methods that perform various operations on collections
The document discusses Java collections and the Google Collections library. It provides an overview of common collection interfaces like List, Set, Queue and Map in Java and their implementations. It also describes additional collection types and utilities provided by the Google Collections library, such as Multimap, Multiset, BiMap, Immutable collections and functional programming utilities like Predicates and Functions.
This document provides an overview of the Java Collections Framework. It discusses core collection interfaces like List, Set, and Map and their common implementations like ArrayList, HashSet, and HashMap. It also covers sorting collections with Comparable and Comparator, searching collections with binary search, and using utility methods in the Collections class. Examples are provided to illustrate usage of various collection classes and methods.
This document discusses Java collections framework and various collection classes like ArrayList, LinkedList, HashSet, HashMap etc. It provides definitions and examples of commonly used collection interfaces like List, Set and Map. It explains key features of different collection classes like order, duplicates allowed, synchronization etc. Iterators and generic types are also covered with examples to iterate and create typed collection classes.
This document discusses the collection framework in Java. It provides an overview of the need for collections due to limitations of arrays. It then describes the key interfaces in the collection framework - Collection, List, Set, SortedSet, NavigableSet, Queue, Map, SortedMap, and NavigableMap. For each interface, it provides a brief description of its purpose and characteristics. It explains that collections allow storing heterogeneous data types with variable sizes, unlike arrays.
The Java Collection Framework provides interfaces and implementations for commonly used data structures like lists, sets, maps and queues. Some key interfaces include Collection, Set, List, Map and SortedSet. Common implementations are ArrayList, LinkedList, HashSet, TreeSet, HashMap and TreeMap. The framework also includes iterators for traversing collections and algorithms for sorting. Generic types were introduced in Java 5 for type-safe collections.
The document provides information about Java's collection framework. It discusses the key interfaces like List, Set, and Map. It describes common implementations of these interfaces like ArrayList, LinkedList, HashSet, TreeSet, HashMap. It explains concepts like iterators, storage of elements in ArrayList and Vector, differences between ArrayList and Vector. It also provides examples of using ArrayList, Vector, HashSet and TreeMap.
Collections in Java include arrays, iterators, and interfaces like Collection, Set, List, and Map. Arrays have advantages like type checking and known size but are fixed. Collections generalize arrays, allowing resizable and heterogeneous groups through interfaces implemented by classes like ArrayList, LinkedList, HashSet and HashMap. Common operations include adding, removing, and iterating over elements.
This presentation introduces some concepts about the Java Collection framework. These slides introduce the following concepts:
- Collections and iterators
- Linked list and array list
- Hash set and tree set
- Maps
- The collection framework
The presentation is took from the Java course I run in the bachelor-level informatics curriculum at the University of Padova.
Java Collections Framework Inroduction with Video TutorialMarcus Biel
This presentation is part of my free Java 8 course focusing on clean code principles. In this piece, you will be given a high-level introduction of the Java Collections Framework (JCF).
You can find the full article with lots of other additional materials here -
http://www.marcus-biel.com/java-collections-framework/
The Java Collections Framework provides a unified architecture for representing and manipulating collections of objects. The framework includes collection interfaces like Set, List, Queue, and Map that define common operations on collections. It also includes general-purpose implementations of these interfaces like HashSet, ArrayList, LinkedList, HashMap, and TreeMap that are backed by common data structures like arrays, linked lists, and trees. The framework aims to allow collections to be manipulated independently of their specific representation.
The Java Collections Framework provides useful classes for storing and processing data efficiently. It includes the List interface which supports ordered elements that may be duplicated. The ArrayList and LinkedList classes implement the List interface but differ in performance - ArrayList uses an array for fast random access while LinkedList uses nodes for fast insertion/removal. The Set interface does not allow duplicates. Implementations like HashSet, TreeSet and LinkedHashSet vary in ordering and performance. The ArrayDeque class implements a double-ended queue for fast insertion/removal at both ends. Collections methods like sort() and reverse() can organize elements in lists.
This document discusses Java generics. Some key points:
- Generics allow data type parameters to be used for classes, interfaces, and methods. This allows code to work with different data types.
- Generics were introduced in JDK 5 and support abstraction over types. The class/method designer can define generic types, while users provide the specific types.
- Common uses of generics include the Java Collection Framework and auto-boxing/unboxing of primitives and wrappers.
- Generics help reuse code by allowing classes, interfaces, and methods to work with different object types. They do not support primitive types like int directly.
- Examples demonstrate generic classes, interfaces, methods,
In this presentation you will learn everything you need to know about ArrayList. I explain the difference of capacity and size, and I introduce you to the methods of the Java ArrayList class, divided by the interfaces java.util.Collection and java.util.List.
The document discusses Java's Collections framework. It provides an overview of Collections and their benefits, describes the core Collections interfaces like Collection, Set, List, Queue, Map, SortedSet and SortedMap. It also discusses common operations, implementations, iteration, algorithms and thread safety considerations for Collections.
This document provides an overview of Java collections including common implementations like lists, maps, and queues. It discusses how collections allow storing and accessing multiple objects, the benefits of generics for type safety, and useful methods in the Collections class for sorting, shuffling, and copying collections. Code examples are provided for creating parameterized lists and maps, sorting lists using Comparator, and exercises for working with collections in practice.
The document discusses the Java Collection Framework which provides interfaces and classes for storing and manipulating groups of objects, including Collection interfaces like List and Set, implementation classes like ArrayList, LinkedList, HashSet and TreeSet, and describes their features and usage.
The java.util package contains commonly used utility classes like collections, dates, and more. The ArrayDeque class implements a double-ended queue and allows insertion and removal from both ends. It uses an array internally and is not thread-safe. Other classes covered include ArrayList, Arrays, BitSet, Calendar, Dictionary, EnumMap, HashMap, HashSet, LinkedHashSet, and Properties.
Java collection classes and their usage.how to use java collections in a program and different types of collections. difference between the map list set, volatile keyword.
The document discusses the Java Collections Framework, which includes interfaces like Collection, List, Set, and Map. It describes common implementations like ArrayList, LinkedList, HashSet, TreeSet, HashMap, and LinkedHashMap. It covers the core functionality provided by the interfaces and benefits of using the framework.
The document summarizes various collection classes in Java, including Collection, List, Set, and Map interfaces and their common implementations like ArrayList, LinkedList, HashSet, TreeSet, HashMap, and TreeMap. It discusses the pros and cons of different collection classes and how to iterate through collections using iterators to avoid ConcurrentModificationExceptions.
The document discusses Java collections and common collection classes. It begins by defining collections as a framework for storing and manipulating groups of objects. It then covers key collection interfaces like Set, List, Queue, and Deque. Common collection classes discussed include ArrayList, LinkedList, HashSet, TreeSet, PriorityQueue, and ArrayDeque. The document provides details on constructors, methods, and examples for many of the collection classes.
The document discusses various Java Collection interfaces and classes. It provides details about List, Set, Queue interfaces and how they are implemented by classes like ArrayList, LinkedList, Vector etc. It also describes some key methods in the List interface like add, remove, get etc and explains concepts like iterators.
This document provides an overview of the Java Collections Framework. It discusses core collection interfaces like List, Set, and Map and their common implementations like ArrayList, HashSet, and HashMap. It also covers sorting collections with Comparable and Comparator, searching collections with binary search, and using utility methods in the Collections class. Examples are provided to illustrate usage of various collection classes and methods.
This document discusses Java collections framework and various collection classes like ArrayList, LinkedList, HashSet, HashMap etc. It provides definitions and examples of commonly used collection interfaces like List, Set and Map. It explains key features of different collection classes like order, duplicates allowed, synchronization etc. Iterators and generic types are also covered with examples to iterate and create typed collection classes.
This document discusses the collection framework in Java. It provides an overview of the need for collections due to limitations of arrays. It then describes the key interfaces in the collection framework - Collection, List, Set, SortedSet, NavigableSet, Queue, Map, SortedMap, and NavigableMap. For each interface, it provides a brief description of its purpose and characteristics. It explains that collections allow storing heterogeneous data types with variable sizes, unlike arrays.
The Java Collection Framework provides interfaces and implementations for commonly used data structures like lists, sets, maps and queues. Some key interfaces include Collection, Set, List, Map and SortedSet. Common implementations are ArrayList, LinkedList, HashSet, TreeSet, HashMap and TreeMap. The framework also includes iterators for traversing collections and algorithms for sorting. Generic types were introduced in Java 5 for type-safe collections.
The document provides information about Java's collection framework. It discusses the key interfaces like List, Set, and Map. It describes common implementations of these interfaces like ArrayList, LinkedList, HashSet, TreeSet, HashMap. It explains concepts like iterators, storage of elements in ArrayList and Vector, differences between ArrayList and Vector. It also provides examples of using ArrayList, Vector, HashSet and TreeMap.
Collections in Java include arrays, iterators, and interfaces like Collection, Set, List, and Map. Arrays have advantages like type checking and known size but are fixed. Collections generalize arrays, allowing resizable and heterogeneous groups through interfaces implemented by classes like ArrayList, LinkedList, HashSet and HashMap. Common operations include adding, removing, and iterating over elements.
This presentation introduces some concepts about the Java Collection framework. These slides introduce the following concepts:
- Collections and iterators
- Linked list and array list
- Hash set and tree set
- Maps
- The collection framework
The presentation is took from the Java course I run in the bachelor-level informatics curriculum at the University of Padova.
Java Collections Framework Inroduction with Video TutorialMarcus Biel
This presentation is part of my free Java 8 course focusing on clean code principles. In this piece, you will be given a high-level introduction of the Java Collections Framework (JCF).
You can find the full article with lots of other additional materials here -
http://www.marcus-biel.com/java-collections-framework/
The Java Collections Framework provides a unified architecture for representing and manipulating collections of objects. The framework includes collection interfaces like Set, List, Queue, and Map that define common operations on collections. It also includes general-purpose implementations of these interfaces like HashSet, ArrayList, LinkedList, HashMap, and TreeMap that are backed by common data structures like arrays, linked lists, and trees. The framework aims to allow collections to be manipulated independently of their specific representation.
The Java Collections Framework provides useful classes for storing and processing data efficiently. It includes the List interface which supports ordered elements that may be duplicated. The ArrayList and LinkedList classes implement the List interface but differ in performance - ArrayList uses an array for fast random access while LinkedList uses nodes for fast insertion/removal. The Set interface does not allow duplicates. Implementations like HashSet, TreeSet and LinkedHashSet vary in ordering and performance. The ArrayDeque class implements a double-ended queue for fast insertion/removal at both ends. Collections methods like sort() and reverse() can organize elements in lists.
This document discusses Java generics. Some key points:
- Generics allow data type parameters to be used for classes, interfaces, and methods. This allows code to work with different data types.
- Generics were introduced in JDK 5 and support abstraction over types. The class/method designer can define generic types, while users provide the specific types.
- Common uses of generics include the Java Collection Framework and auto-boxing/unboxing of primitives and wrappers.
- Generics help reuse code by allowing classes, interfaces, and methods to work with different object types. They do not support primitive types like int directly.
- Examples demonstrate generic classes, interfaces, methods,
In this presentation you will learn everything you need to know about ArrayList. I explain the difference of capacity and size, and I introduce you to the methods of the Java ArrayList class, divided by the interfaces java.util.Collection and java.util.List.
The document discusses Java's Collections framework. It provides an overview of Collections and their benefits, describes the core Collections interfaces like Collection, Set, List, Queue, Map, SortedSet and SortedMap. It also discusses common operations, implementations, iteration, algorithms and thread safety considerations for Collections.
This document provides an overview of Java collections including common implementations like lists, maps, and queues. It discusses how collections allow storing and accessing multiple objects, the benefits of generics for type safety, and useful methods in the Collections class for sorting, shuffling, and copying collections. Code examples are provided for creating parameterized lists and maps, sorting lists using Comparator, and exercises for working with collections in practice.
The document discusses the Java Collection Framework which provides interfaces and classes for storing and manipulating groups of objects, including Collection interfaces like List and Set, implementation classes like ArrayList, LinkedList, HashSet and TreeSet, and describes their features and usage.
The java.util package contains commonly used utility classes like collections, dates, and more. The ArrayDeque class implements a double-ended queue and allows insertion and removal from both ends. It uses an array internally and is not thread-safe. Other classes covered include ArrayList, Arrays, BitSet, Calendar, Dictionary, EnumMap, HashMap, HashSet, LinkedHashSet, and Properties.
Java collection classes and their usage.how to use java collections in a program and different types of collections. difference between the map list set, volatile keyword.
The document discusses the Java Collections Framework, which includes interfaces like Collection, List, Set, and Map. It describes common implementations like ArrayList, LinkedList, HashSet, TreeSet, HashMap, and LinkedHashMap. It covers the core functionality provided by the interfaces and benefits of using the framework.
The document summarizes various collection classes in Java, including Collection, List, Set, and Map interfaces and their common implementations like ArrayList, LinkedList, HashSet, TreeSet, HashMap, and TreeMap. It discusses the pros and cons of different collection classes and how to iterate through collections using iterators to avoid ConcurrentModificationExceptions.
The document discusses Java collections and common collection classes. It begins by defining collections as a framework for storing and manipulating groups of objects. It then covers key collection interfaces like Set, List, Queue, and Deque. Common collection classes discussed include ArrayList, LinkedList, HashSet, TreeSet, PriorityQueue, and ArrayDeque. The document provides details on constructors, methods, and examples for many of the collection classes.
The document discusses various Java Collection interfaces and classes. It provides details about List, Set, Queue interfaces and how they are implemented by classes like ArrayList, LinkedList, Vector etc. It also describes some key methods in the List interface like add, remove, get etc and explains concepts like iterators.
The document discusses data structures and provides examples of using common Java collection classes like ArrayList and LinkedList. It also covers implementing stack, queue, and tree data structures. Specific examples include counting internet addresses, number base conversion using a stack, and building queue and binary tree classes.
The document discusses Java collections and generics. It provides an overview of collection interfaces like List, Set, Queue and their implementations like ArrayList, LinkedList, HashSet. It also covers generics concepts like type parameters, generic methods and constructors. Sample programs demonstrate how to use ArrayList, PriorityQueue and generic methods. The key benefits of collections framework are reducing programming effort and increasing program speed and quality.
This document provides an overview of Java collections frameworks. It defines collections as objects that group multiple elements and discusses their uses for storing, retrieving, and manipulating data. It describes the main interfaces in the collections hierarchy including Iterator, List, Queue, and Set. It also explains common implementation classes for each interface like ArrayList, LinkedList, PriorityQueue, HashSet and TreeSet. The conclusion reinforces that the collections framework provides a consistent and modular way to work with grouped data in Java programs.
This document provides an overview of Java collections and common collection interfaces like List, Set, Map, Queue, and their implementations. It discusses the core collection interfaces like Collection, List, Set, Map, Queue, and their methods. Specific implementations of these interfaces are covered like ArrayList, LinkedList, HashSet, TreeSet, HashMap, TreeMap, PriorityQueue. The document is presented by Ravi Kant Sahu, Assistant Professor at Lovely Professional University in Punjab, India and provides details on using collections in Java.
This document provides an overview of a lecture on data structures. It discusses how data structures prepare students for advanced courses and covers common structures like arrays, linked lists, stacks, queues, trees and graphs. It implements these in C++. The grading breakdown is provided. Key concepts are defined, like what a data structure is and why they are needed. Examples of various data structures are outlined like arrays, linked lists, stacks and queues. Arrays are described in more detail about how they are declared and accessed.
This chapter discusses different data structures including lists, stacks, queues, and trees. It covers the ArrayList and LinkedList classes in Java and how to implement stack, queue, and tree structures. Examples are provided to demonstrate counting IP addresses from a file using an ArrayList and LinkedList, converting a number to a different base using a stack, and building a queue class with a LinkedList. The chapter introduces binary trees and their applications.
This document provides an overview of a lecture on R. The lecture will cover what R is and why to use it, setting up R and RStudio, performing calculations and functions in R, handling files and creating plots and graphics, performing statistical analyses, and writing functions. It also discusses R's strengths like data management, statistics, graphics, and its active user community, as well as weaknesses like not being very user friendly initially and being slower than other programming languages.
This document provides an overview and introduction to data structures in Pascal, including file input/output, arrays, records, pointers, linked lists, stacks, and queues. It discusses basic Pascal concepts like data types, variables, conditionals, and loops. It then covers specific data structure topics like single and multi-dimensional arrays, selection sort, searching arrays, records, variants, binary files, sets, abstract data types, strings, and linked lists implemented using both arrays and pointers. Exercises are provided at the end of each section to reinforce the concepts.
In this core java training session, you will learn Collections – Lists, Sets. Topics covered in this session are:
• List – ArrayList, LinkedList
• Set – HashSet, LinkedHashSet, TreeSet
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
The document provides information about Java Collection Framework. It discusses that the Collection Framework provides a unified architecture for storing and manipulating groups of objects through interfaces like Set, List, Queue etc. and their implementation classes like ArrayList, LinkedList etc. It also describes various collection interfaces like Collection, List, Queue, Deque and Iterator along with their methods. It provides examples of using ArrayList and LinkedList to demonstrate common collection operations.
This document provides an introduction to Java data structures and the Java Collections Framework. It begins with an overview of the instructor and course topics, which include arrays, the Collections Framework, and collection algorithms. It then covers arrays in more detail, including how to declare, initialize, and access array elements. Next, it discusses the Collection interface and some common methods. It introduces the main collection interfaces in Java - List, Set, and Map - and some common implementations. It provides examples of using arrays, Lists, Sets and Maps. Finally, it summarizes the benefits of the Collections Framework and lists some key methods for the main collection interfaces.
This document discusses data structures using C++. It begins with an introduction to data structures and their classification as primitive and non-primitive. Linear and non-linear data structures are described. Arrays are discussed in detail, including their representation in memory, types of arrays, and common operations like traversal, insertion, deletion, searching and sorting. Two-dimensional arrays are also introduced.
The Collection in Java is a framework that provides an architecture to store and manipulate the group of objects.
All the operations that you perform on a data such as searching, sorting, insertion, manipulation, deletion, etc. can be achieved by Java Collections.
Java Collection means a single unit of objects. Java Collection framework provides many interfaces (Set, List, Queue, Deque, etc.) and classes (ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet, etc.).
The document discusses reading and manipulating data in R. It describes how to read different file types like CSV, Excel, SAS, Stata and text files into R objects using various packages and functions. It also explains different data objects in R like vectors, arrays, lists and data frames, and how to access elements within these objects using indexes or names.
This document provides an introduction and overview of data structures. It defines data structures as specialized formats for organizing and storing data to improve efficiency of storage and processing. It classifies data structures as primitive, non-primitive, linear, and non-linear. Primitive structures include basic types like integers while non-primitive structures are derived groups like arrays and lists. Common operations on data structures like traversal, insertion, and deletion are also discussed.
This document discusses different data structures including arrays, lists, stacks, and queues. It begins by reviewing the limitations of arrays and how collection classes like ArrayList and LinkedList address those limitations by allowing dynamic resizing. It then provides examples of using ArrayList and LinkedList to count IP addresses from a file. Key differences between ArrayList and LinkedList are explained, such as ArrayList using an array under the hood while LinkedList uses linked nodes. The efficiency of various operations on each is analyzed. The document also introduces stack and queue data structures and provides an example stack class for converting numbers between bases. It notes Java's built-in Stack class extends from Vector inappropriately.
This document discusses methods of proof and disproof in logic. It defines proof as establishing that a conditional statement is true using logic, and disproof as establishing a conditional is false. There are three types of proof: direct proof, indirect proof, and proof by contradiction. Direct proof assumes the if-part is true and derives the then-part. Indirect proof proves the contrapositive. Proof by contradiction assumes a statement is false and derives a contradiction. There are two types of disproof: disproof by contradiction and disproof by counterexamples. The document provides examples of applying these methods to prove or disprove conditional statements about integers.
This document discusses quantifiers and open statements. It defines universal and existential quantifiers and provides examples of open statements involving variables. Several quantified statements are expressed symbolically and evaluated for truth value. Universal statements about integers being perfect squares, positive, even, or divisible by 3 or 7 are determined to be true or false.
The document discusses various HTML elements and their usage in creating web pages. It describes common elements like headings, paragraphs, lists, links and images. It also explains the structure of an HTML document with root, head and body elements. The head contains meta information while the body contains the visible page content. Semantic elements are recommended for accessibility, maintenance and search engine optimization.
Discrete Mathematical Structures
Fundamentals of Logic
NAND, NOR COnnectives
Representing the given compound proposition in terms of only NAND and/or NOR connectives
Discrete Mathematical Structures - Fundamentals of Logic - Principle of dualityLakshmi R
This document discusses the principle of duality in logic. It defines duality as replacing logical connectives ∧ with ∨, and vice versa, in a statement. The dual of statement s (written as sd) is obtained by making these replacements. The document proves that if two statements s and t are logically equivalent, then their duals sd and td are also equivalent. It provides examples of taking the dual of statements and verifies the principle of duality for a given logical equivalence.
The document discusses fundamentals of logic including propositions, truth values, logical connectives, and examples. It defines a proposition as a statement that can be either true or false, but not both. Truth values are defined as the truth or falsity of a proposition. Logical connectives like negation, conjunction, disjunction are introduced to form compound propositions from simple propositions. Several examples are given to illustrate logical connectives and truth tables are used to determine truth values of compound propositions. Problems involving determining truth values and identifying tautologies, contradictions and contingencies are also presented.
The document discusses rules of inference in logic. It begins by defining an argument as having premises and a conclusion. Several common rules of inference are then outlined, including modus ponens, modus tollens, and disjunctive syllogism. The remainder of the document works through examples of arguments and tests their validity using the rules of inference. It symbolically represents the arguments and shows the step-by-step workings to determine if the conclusions follow logically from the premises.
The document discusses Java Server Pages (JSP) technology which allows creating dynamic web content that has both static and dynamic components. It describes the main features of JSP including processing requests and responses. It then covers the JSP lifecycle and various JSP constructs like declarations, expressions, scriptlets, and directives. It provides examples of using these constructs and also discusses implicit objects, cookies, sessions in JSP.
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceIndexBug
Imagine a world where machines not only perform tasks but also learn, adapt, and make decisions. This is the promise of Artificial Intelligence (AI), a technology that's not just enhancing our lives but revolutionizing entire industries.
Building Production Ready Search Pipelines with Spark and MilvusZilliz
Spark is the widely used ETL tool for processing, indexing and ingesting data to serving stack for search. Milvus is the production-ready open-source vector database. In this talk we will show how to use Spark to process unstructured data to extract vector representations, and push the vectors to Milvus vector database for search serving.
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/building-and-scaling-ai-applications-with-the-nx-ai-manager-a-presentation-from-network-optix/
Robin van Emden, Senior Director of Data Science at Network Optix, presents the “Building and Scaling AI Applications with the Nx AI Manager,” tutorial at the May 2024 Embedded Vision Summit.
In this presentation, van Emden covers the basics of scaling edge AI solutions using the Nx tool kit. He emphasizes the process of developing AI models and deploying them globally. He also showcases the conversion of AI models and the creation of effective edge AI pipelines, with a focus on pre-processing, model conversion, selecting the appropriate inference engine for the target hardware and post-processing.
van Emden shows how Nx can simplify the developer’s life and facilitate a rapid transition from concept to production-ready applications.He provides valuable insights into developing scalable and efficient edge AI solutions, with a strong focus on practical implementation.
“An Outlook of the Ongoing and Future Relationship between Blockchain Technologies and Process-aware Information Systems.” Invited talk at the joint workshop on Blockchain for Information Systems (BC4IS) and Blockchain for Trusted Data Sharing (B4TDS), co-located with with the 36th International Conference on Advanced Information Systems Engineering (CAiSE), 3 June 2024, Limassol, Cyprus.
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-und-domino-lizenzkostenreduzierung-in-der-welt-von-dlau/
DLAU und die Lizenzen nach dem CCB- und CCX-Modell sind für viele in der HCL-Community seit letztem Jahr ein heißes Thema. Als Notes- oder Domino-Kunde haben Sie vielleicht mit unerwartet hohen Benutzerzahlen und Lizenzgebühren zu kämpfen. Sie fragen sich vielleicht, wie diese neue Art der Lizenzierung funktioniert und welchen Nutzen sie Ihnen bringt. Vor allem wollen Sie sicherlich Ihr Budget einhalten und Kosten sparen, wo immer möglich. Das verstehen wir und wir möchten Ihnen dabei helfen!
Wir erklären Ihnen, wie Sie häufige Konfigurationsprobleme lösen können, die dazu führen können, dass mehr Benutzer gezählt werden als nötig, und wie Sie überflüssige oder ungenutzte Konten identifizieren und entfernen können, um Geld zu sparen. Es gibt auch einige Ansätze, die zu unnötigen Ausgaben führen können, z. B. wenn ein Personendokument anstelle eines Mail-Ins für geteilte Mailboxen verwendet wird. Wir zeigen Ihnen solche Fälle und deren Lösungen. Und natürlich erklären wir Ihnen das neue Lizenzmodell.
Nehmen Sie an diesem Webinar teil, bei dem HCL-Ambassador Marc Thomas und Gastredner Franz Walder Ihnen diese neue Welt näherbringen. Es vermittelt Ihnen die Tools und das Know-how, um den Überblick zu bewahren. Sie werden in der Lage sein, Ihre Kosten durch eine optimierte Domino-Konfiguration zu reduzieren und auch in Zukunft gering zu halten.
Diese Themen werden behandelt
- Reduzierung der Lizenzkosten durch Auffinden und Beheben von Fehlkonfigurationen und überflüssigen Konten
- Wie funktionieren CCB- und CCX-Lizenzen wirklich?
- Verstehen des DLAU-Tools und wie man es am besten nutzt
- Tipps für häufige Problembereiche, wie z. B. Team-Postfächer, Funktions-/Testbenutzer usw.
- Praxisbeispiele und Best Practices zum sofortigen Umsetzen
2. Collection – Group of objects
Collection Framework –
• Classes and Interfaces that manage collections.
• Provides an architecture to store and manipulate the group of objects.
• Standardizes the way in which group of objects that are handled by
your programs.
Overview
30-12-2017 2Lakshmi R, Asst. Professor, Dept. of ISE
4. • Performance - efficient implementation of data structures like lists, array lists,
trees, set, hash tables and many more. (You don’t have to code manually)
• Interoperability – different types of collections wok in similar manner
• Easy – Extension and Adaption. Collections Framework is built upon a set of
standard interfaces
• Integration of standard arrays to Collection Framework.
• Algorithms – Defined as static methods within the Collection class
• Iterator interface – Standard way of accessing the elements within a collection.
• Each collection implements Iterator. Eg: Code that cycles through a set can be used to cycle
through a list.
Design Goal
30-12-2017 4Lakshmi R, Asst. Professor, Dept. of ISE
6. The Collection Interface
• It is a generic interface.
Declaration :
interface Collection<E>
• Where E represents the type of objects the collection can
hold.
• Collection extends the Iterable interface. (Hence, it can be
cycled through for-each version of for loop)
30-12-2017 6Lakshmi R, Asst. Professor, Dept. of ISE
9. The List Interface
• It is a generic interface.
• List extends Collection interface.
Declaration :
interface List<E>
• Where E represents the type of objects the list can hold.
• List may contain duplicate elements.
30-12-2017 9Lakshmi R, Asst. Professor, Dept. of ISE
11. The Set Interface
• It is a generic interface.
• Set extends Collection interface.
Declaration :
interface Set<E>
• Where E represents the type of objects the set can hold.
• Set doesn’t contain duplicate elements.
• No methods of its own.
30-12-2017 11Lakshmi R, Asst. Professor, Dept. of ISE
12. The SortedSet Interface
• It is a generic interface.
• Set extends Set interface.
Declaration :
interface SortedSet<E>
• Where E represents the type of objects the SortedSet can hold.
• Set doesn’t contain duplicate elements.
• Declares set in ascending order.
30-12-2017 12Lakshmi R, Asst. Professor, Dept. of ISE
14. The Queue Interface
• Queue is a generic interface
• The Queue interface extends Collection
• It declares the behavior of a queue (first-in, first-out list)
Declaration :
interface Queue<E>
30-12-2017 14Lakshmi R, Asst. Professor, Dept. of ISE
16. The Deque Interface
• It extends Queue and declares the behavior of a double-ended queue
• Double-ended queues can function as standard, first-in, first-out
queues or as last-in, first-out stacks.
Declaration :
interface Deque<E>
30-12-2017 16Lakshmi R, Asst. Professor, Dept. of ISE
20. The ArrayList Class
• The ArrayList class extends AbstractList and implements the List
interface
Declaration :
Class ArrayList<E>
Constructors:
ArrayList( ) – Empty array list
ArrayList(Collection<? extends E> c)
ArrayList(int capacity)
30-12-2017 20Lakshmi R, Asst. Professor, Dept. of ISE
21. // Demonstrate ArrayList.
import java.util.*;
class ArrayListDemo {
public static void main(String args[]) {
// Create an array list.
ArrayList<String> al = new ArrayList<String>();
System.out.println("Initial size of al: " + al.size());
// Add elements to the array list.
al.add("C");
al.add("A");
al.add("E");
al.add("B");
al.add("D");
al.add("F");
30-12-2017 21Lakshmi R, Asst. Professor, Dept. of ISE
22. al.add(1, "A2");
System.out.println("Size of al after additions: " + al.size());
// Display the array list.
System.out.println("Contents of al: " + al);
// Remove elements from the array list.
al.remove("F");
al.remove(2);
System.out.println("Size of al after deletions: " +al.size());
System.out.println("Contents of al: " + al); } }
The output from this program is shown here:
Initial size of al: 0
Size of al after additions: 7
Contents of al: [C, A2, A, E, B, D, F]
Size of al after deletions: 5
Contents of al: [C, A2, E, B, D]
30-12-2017 22Lakshmi R, Asst. Professor, Dept. of ISE
23. Obtaining an Array from an ArrayList
// Convert an ArrayList into an array.
import java.util.*;
class ArrayListToArray {
public static void main(String args[]) {
// Create an array list.
ArrayList<Integer> al = new ArrayList<Integer>();
// Add elements to the array list.
al.add(1);
al.add(2);
al.add(3);
al.add(4);
30-12-2017 23Lakshmi R, Asst. Professor, Dept. of ISE
24. System.out.println("Contents of al: " + al);
// Get the array.
Integer ia[] = new Integer[al.size()];
ia = al.toArray(ia);
int sum = 0;
// Sum the array.
for(int i : ia) sum += i;
System.out.println("Sum is: " + sum);
}
}
The output from the program is shown here:
Contents of al: [1, 2, 3, 4]
Sum is: 10
30-12-2017 24Lakshmi R, Asst. Professor, Dept. of ISE
25. The LinkedList Class
• The LinkedList class extends AbstractSequentialList
• Implements the List, Deque, and Queue interfaces
• LinkedList is a generic class
Declaration :
Class LinkedList<E>
Constructors:
LinkedList( ) – Empty linked list
LinkedList(Collection<? extends E> c)
30-12-2017 25Lakshmi R, Asst. Professor, Dept. of ISE
26. // Demonstrate LinkedList.
import java.util.*;
class LinkedListDemo {
public static void main(String args[]) {
// Create a linked list.
LinkedList<String> ll = new LinkedList<String>();
// Add elements to the linked list.
ll.add("F");
ll.add("B");
ll.add("D");
ll.add("E");
ll.add("C");
ll.addLast("Z");
ll.addFirst("A");
ll.add(1, "A2");
30-12-2017 26Lakshmi R, Asst. Professor, Dept. of ISE
27. // Remove elements from the linked list.
ll.remove("F");
ll.remove(2);
System.out.println("Contents of ll after deletion: "+ ll);
// Remove first and last elements.
ll.removeFirst();
ll.removeLast();
System.out.println("ll after deleting first and last: "+ ll);
// Get and set a value.
String val = ll.get(2);
ll.set(2, val + " Changed");
System.out.println("ll after change: " + ll);
}
}
30-12-2017 27Lakshmi R, Asst. Professor, Dept. of ISE
28. The output from this program is shown here:
Original contents of ll: [A, A2, F, B, D, E, C, Z]
Contents of ll after deletion: [A, A2, D, E, C, Z]
ll after deleting first and last: [A2, D, E, C]
ll after change: [A2, D, E Changed, C]
30-12-2017 28Lakshmi R, Asst. Professor, Dept. of ISE
29. The HashSet Class
• HashSet extends AbstractSet and implements the Set interface
Declaration
class HashSet<E>
Constructors
HashSet( ) – Default size 16
HashSet(Collection<? extends E> c)
HashSet(int capacity)
HashSet(int capacity, float fillRatio)
30-12-2017 29Lakshmi R, Asst. Professor, Dept. of ISE
30. // Demonstrate HashSet.
import java.util.*;
class HashSetDemo {
public static void main(String args[]) {
// Create a hash set.
HashSet<String> hs = new HashSet<String>();
// Add elements to the hash set.
hs.add("B");
hs.add("A");
hs.add("D");
hs.add("E");
hs.add("C");
hs.add("F");
System.out.println(hs);
}
}
The following is the output from this program:
[D, A, F, C, B, E]
30-12-2017 30Lakshmi R, Asst. Professor, Dept. of ISE
31. The LinkedHashSet Class
• The LinkedHashSet class extends HashSet
Declaration
class LinkedHashSet<E>
• Uses linked list to store hash set.
30-12-2017 31Lakshmi R, Asst. Professor, Dept. of ISE
32. The TreeSet Class
Declaration:
class TreeSet<E>
TreeSet( )
TreeSet(Collection<? extends E> c)
TreeSet(Comparator<? super E> comp)
TreeSet(SortedSet<E> ss)
30-12-2017 32Lakshmi R, Asst. Professor, Dept. of ISE
33. // Demonstrate TreeSet.
import java.util.*;
class TreeSetDemo {
public static void main(String args[]) {
// Create a tree set.
TreeSet<String> ts = new TreeSet<String>();
// Add elements to the tree set.
ts.add("C");
ts.add("A");
ts.add("B");
ts.add("E");
ts.add("F");
ts.add("D");
System.out.println(ts);
}
}
The output from this program is shown here:
[A, B, C, D, E, F]
30-12-2017 33Lakshmi R, Asst. Professor, Dept. of ISE
34. The PriorityQueue Class
• PriorityQueue extends AbstractQueue and implements the Queue
interface
Declaration
class PriorityQueue<E>
Constructors
PriorityQueue( ) – Starting Capacity is 11
PriorityQueue(int capacity)
PriorityQueue(int capacity, Comparator<? super E> comp)
PriorityQueue(Collection<? extends E> c)
PriorityQueue(PriorityQueue<? extends E> c)
PriorityQueue(SortedSet<? extends E> c)
30-12-2017 34Lakshmi R, Asst. Professor, Dept. of ISE
35. The ArrayDeque Class
• It extends AbstractCollection and implements the Deque interface
Declaration
class ArrayDeque<E>
Constuctors:
ArrayDeque( ) – Starting Capacity 16
ArrayDeque(int size)
ArrayDeque(Collection<? extends E> c)
30-12-2017 35Lakshmi R, Asst. Professor, Dept. of ISE
36. Accessing a Collection via an Iterator
interface Iterator<E> - Single Directional Traversal
interface ListIterator<E> - Bidirectional Traversal
30-12-2017 36Lakshmi R, Asst. Professor, Dept. of ISE
38. // Demonstrate iterators.
import java.util.*;
class IteratorDemo {
public static void main(String args[]) {
// Create an array list.
ArrayList<String> al = new ArrayList<String>();
// Add elements to the array list.
al.add("C");
al.add("A");
al.add("E");
al.add("B");
al.add("D");
al.add("F");
30-12-2017 38Lakshmi R, Asst. Professor, Dept. of ISE
39. // Use iterator to display contents of al.
System.out.print("Original contents of al: ");
Iterator<String> itr = al.iterator();
while(itr.hasNext()) {
String element = itr.next();
System.out.print(element + " ");
}
System.out.println();
// Modify objects being iterated.
ListIterator<String> litr = al.listIterator();
while(litr.hasNext()) {
String element = litr.next();
litr.set(element + "+");
}
30-12-2017 39Lakshmi R, Asst. Professor, Dept. of ISE
40. System.out.print("Modified contents of al: ");
itr = al.iterator();
while(itr.hasNext()) {
String element = itr.next();
System.out.print(element + " ");
}
System.out.println();
// Now, display the list backwards.
System.out.print("Modified list backwards: ");
while(litr.hasPrevious()) {
String element = litr.previous();
System.out.print(element + " ");
}
System.out.println();
}
}
The output is shown here:
Original contents of al: C A E B D F
Modified contents of al: C+ A+ E+ B+ D+ F+
Modified list backwards: F+ D+ B+ E+ A+ C+
30-12-2017 40Lakshmi R, Asst. Professor, Dept. of ISE
41. The For-Each Alternative to Iterators
// Use the for-each for loop to cycle through a collection.
import java.util.*;
class ForEachDemo {
public static void main(String args[]) {
// Create an array list for integers.
ArrayList<Integer> vals = new ArrayList<Integer>();
// Add values to the array list.
vals.add(1);
vals.add(2);
vals.add(3);
vals.add(4);
vals.add(5);
30-12-2017 41Lakshmi R, Asst. Professor, Dept. of ISE
42. // Use for loop to display the values.
System.out.print("Original contents of vals: ");
for(int v : vals)
System.out.print(v + " ");
System.out.println();
// Now, sum the values by using a for loop.
int sum = 0;
for(int v : vals)
sum += v;
System.out.println("Sum of values: " + sum);
}
}
The output from the program is shown here:
Original contents of vals: 1 2 3 4 5
Sum of values: 15
30-12-2017 42Lakshmi R, Asst. Professor, Dept. of ISE
43. Storing User-Defined Classes in Collections
// A simple mailing list example.
import java.util.*;
class Address {
private String name;
private String street;
private String city;
private String state;
private String code;
Address(String n, String s, String c,
String st, String cd) {
name = n;
street = s;
city = c;
state = st;
code = cd;
}
public String toString() {
return name + "n" + street + "n" +
city + " " + state + " " + code; } }30-12-2017 43Lakshmi R, Asst. Professor, Dept. of ISE
44. class MailList {
public static void main(String args[]) {
LinkedList<Address> ml = new LinkedList<Address>();
// Add elements to the linked list.
ml.add(new Address("J.W. West", "11 Oak Ave","Urbana", "IL", "61801"));
ml.add(new Address("Ralph Baker", "1142 Maple Lane","Mahomet", "IL",
"61853"));
ml.add(new Address("Tom Carlton", "867 Elm St","Champaign", "IL",61820"));
// Display the mailing list.
for(Address element : ml)
System.out.println(element + "n");
System.out.println();
}
}
30-12-2017 44Lakshmi R, Asst. Professor, Dept. of ISE
45. Working with Maps
• A map is an object that stores associations between keys and values,
or key/value pairs.
• Given a key, you can find its value. Both keys and values are objects.
• The keys must be unique, but the values may be duplicated.
30-12-2017 45Lakshmi R, Asst. Professor, Dept. of ISE
46. The Map Interface
• The Map interface maps unique keys to values. A key is an object that
you use to retrieve a value at a later date.
• Given a key and a value, you can store the value in a Map object.
• After the value is stored, you can retrieve it by using its key.
Declaration:
interface Map<K, V>
30-12-2017 46Lakshmi R, Asst. Professor, Dept. of ISE
48. The SortedMap Interface
• The SortedMap interface extends Map.
• It ensures that the entries are maintained in ascending order based
on the keys.
• SortedMap is generic
Declaration
interface SortedMap<K, V>
30-12-2017 48Lakshmi R, Asst. Professor, Dept. of ISE
50. The Map.Entry Interface
• The Map.Entry interface enables you to work with a map entry.
30-12-2017 50Lakshmi R, Asst. Professor, Dept. of ISE
51. The Map Classes
The HashMap Class
HashMap is a generic class that has this declaration:
class HashMap<K, V>
Constructors:
HashMap( )
HashMap(Map<? extends K, ? extends V> m)
HashMap(int capacity)
HashMap(int capacity, float fillRatio)
30-12-2017 51Lakshmi R, Asst. Professor, Dept. of ISE
52. import java.util.*;
class HashMapDemo {
public static void main(String args[]) {
// Create a hash map.
HashMap<String, Double> hm = new HashMap<String, Double>();
// Put elements to the map
hm.put("John Doe", new Double(3434.34));
hm.put("Tom Smith", new Double(123.22));
hm.put("Jane Baker", new Double(1378.00));
hm.put("Tod Hall", new Double(99.22));
hm.put("Ralph Smith", new Double(-19.08));
30-12-2017 52Lakshmi R, Asst. Professor, Dept. of ISE
53. // Get a set of the entries.
Set<Map.Entry<String, Double>> set = hm.entrySet();
// Display the set.
for(Map.Entry<String, Double> me : set) {
System.out.print(me.getKey() + ": ");
System.out.println(me.getValue());
}
System.out.println();
// Deposit 1000 into John Doe's account.
double balance = hm.get("John Doe");
hm.put("John Doe", balance + 1000);
System.out.println("John Doe's new balance: " +
hm.get("John Doe"));
}
}
30-12-2017 53Lakshmi R, Asst. Professor, Dept. of ISE
54. The TreeMap Class
Declaration:
class TreeMap<K, V>
Constructors:
TreeMap( )
TreeMap(Comparator<? super K> comp)
TreeMap(Map<? extends K, ? extends V> m)
TreeMap(SortedMap<K, ? extends V> sm)
30-12-2017 54Lakshmi R, Asst. Professor, Dept. of ISE
55. import java.util.*;
class TreeMapDemo {
public static void main(String args[]) {
// Create a tree map.
TreeMap<String, Double> tm = new TreeMap<String, Double>();
// Put elements to the map.
tm.put("John Doe", new Double(3434.34));
tm.put("Tom Smith", new Double(123.22));
tm.put("Jane Baker", new Double(1378.00));
tm.put("Tod Hall", new Double(99.22));
tm.put("Ralph Smith", new Double(-19.08));
30-12-2017 55Lakshmi R, Asst. Professor, Dept. of ISE
56. // Get a set of the entries.
Set<Map.Entry<String, Double>> set = tm.entrySet();
// Display the elements.
for(Map.Entry<String, Double> me : set) {
System.out.print(me.getKey() + ": ");
System.out.println(me.getValue());
}
System.out.println();
// Deposit 1000 into John Doe's account.
double balance = tm.get("John Doe");
tm.put("John Doe", balance + 1000);
System.out.println("John Doe's new balance: " +
tm.get("John Doe"));
}
} 30-12-2017 56Lakshmi R, Asst. Professor, Dept. of ISE
57. Using Comparator
• Java Comparator interface is used to order the objects of user-
defined class.
• A comparator object is capable of comparing two objects of two
different classes
Methods:
int compare(T obj1, T obj2)
boolean equals(Object obj)
30-12-2017 57Lakshmi R, Asst. Professor, Dept. of ISE
58. // Use a custom comparator.
import java.util.*;
// A reverse comparator for strings.
class MyComp implements Comparator<String> {
public int compare(String a, String b) {
String aStr, bStr;
aStr = a;
bStr = b;
// Reverse the comparison.
return bStr.compareTo(aStr);
}
// No need to override equals.
}
30-12-2017 58Lakshmi R, Asst. Professor, Dept. of ISE
59. class CompDemo {
public static void main(String args[]) {
// Create a tree set.
TreeSet<String> ts = new TreeSet<String>(new
MyComp());
// Add elements to the tree set.
ts.add("C");
ts.add("A");
ts.add("B");
ts.add("E");
ts.add("F");
ts.add("D");
// Display the elements.
for(String element : ts)
System.out.print(element + " ");
System.out.println(); } }
As the following output shows, the tree
is now stored in reverse order:
F E D C B A
30-12-2017 59Lakshmi R, Asst. Professor, Dept. of ISE
60. class Arrays
• It provides various methods that are useful when working with arrays
• These methods help bridge the gap between collections and arrays
asList( ) method – it returns List view of an array
static <T> List asList(T ... array)
Here, array is the array that contains the data.
30-12-2017 60Lakshmi R, Asst. Professor, Dept. of ISE
61. Methods defined in Arrays
• The binarySearch( ) method
• The copyOf() method
• The copyOfRange( ) method
• The equals( ) method
• The fill( ) method
• The sort( ) method
30-12-2017 61Lakshmi R, Asst. Professor, Dept. of ISE
62. The binarySearch( ) method – various forms
• On successful search, it returns position of the key element in specified
array. Otherwise returns negative value.
static int binarySearch(byte array[ ], byte value)
static int binarySearch(char array[ ], char value)
static int binarySearch(double array[ ], double value)
static int binarySearch(float array[ ], float value)
static int binarySearch(int array[ ], int value)
static int binarySearch(long array[ ], long value)
static int binarySearch(short array[ ], short value)
static int binarySearch(Object array[ ], Object value)
static <T> int binarySearch(T[ ] array, T value, Comparator<? super T> c)
30-12-2017 62Lakshmi R, Asst. Professor, Dept. of ISE
63. The copyOf() method – various forms
• It returns a copy of an array.
• The original array is specified by source and the length of the copy is
specified by len.
• If the copy is longer than source, then
• the copy is padded with zeroes for numeric arrays
• nulls for object arrays
• false for boolean arrays
• If the copy is shorter than source, then the copy is truncated
Various forms:
static boolean[ ] copyOf(boolean[ ] source, int len)
static byte[ ] copyOf(byte[ ] source, int len)
static char[ ] copyOf(char[ ] source, int len)
30-12-2017 63Lakshmi R, Asst. Professor, Dept. of ISE
64. static double[ ] copyOf(double[ ] source, int len)
static float[ ] copyOf(float[ ] source, int len)
static int[ ] copyOf(int[ ] source, int len)
static long[ ] copyOf(long[ ] source, int len)
static short[ ] copyOf(short[ ] source, int len)
static <T> T[ ] copyOf(T[ ] source, int len)
static <T,U> T[ ] copyOf(U[ ] source, int len, Class<? extends T[ ]> resultT)
• the type of resultT becomes the type of the array returned.
30-12-2017 64Lakshmi R, Asst. Professor, Dept. of ISE
65. The copyOfRange( ) method – various forms
static boolean[ ] copyOfRange(boolean[ ] source, int start, int end)
static byte[ ] copyOfRange(byte[ ] source, int start, int end)
static char[ ] copyOfRange(char[ ] source, int start, int end)
static double[ ] copyOfRange(double[ ] source, int start, int end)
static float[ ] copyOfRange(float[ ] source, int start, int end)
static int[ ] copyOfRange(int[ ] source, int start, int end)
static long[ ] copyOfRange(long[ ] source, int start, int end)
static short[ ] copyOfRange(short[ ] source, int start, int end)
static <T> T[ ] copyOfRange(T[ ] source, int start, int end)
static <T,U> T[ ] copyOfRange(U[ ] source, int start, int end, Class<? extends T[ ]>
resultT)
30-12-2017 65Lakshmi R, Asst. Professor, Dept. of ISE
66. The equals( ) method
• returns true if two arrays are equivalent. Otherwise, it returns false.
static boolean equals(boolean array1[ ], boolean array2[ ])
static boolean equals(byte array1[ ], byte array2[ ])
static boolean equals(char array1[ ], char array2[ ])
static boolean equals(double array1[ ], double array2[ ])
static boolean equals(float array1[ ], float array2[ ])
static boolean equals(int array1[ ], int array2[ ])
static boolean equals(long array1[ ], long array2[ ])
static boolean equals(short array1[ ], short array2[ ])
static boolean equals(Object array1[ ], Object array2[ ])
30-12-2017 66Lakshmi R, Asst. Professor, Dept. of ISE
67. The fill( ) method – Version 1
• Assigns a value to all elements in an array
• It fills an array with a specified value
static void fill(boolean array[ ], boolean value)
static void fill(byte array[ ], byte value)
static void fill(char array[ ], char value)
static void fill(double array[ ], double value)
static void fill(float array[ ], float value)
static void fill(int array[ ], int value)
static void fill(long array[ ], long value)
static void fill(short array[ ], short value)
static void fill(Object array[ ], Object value)
30-12-2017 67Lakshmi R, Asst. Professor, Dept. of ISE
68. The fill( ) method – Version 2
• assigns a value to a subset of an array
static void fill(boolean array[ ], int start, int end, boolean value)
static void fill(byte array[ ], int start, int end, byte value)
static void fill(char array[ ], int start, int end, char value)
static void fill(double array[ ], int start, int end, double value)
static void fill(float array[ ], int start, int end, float value)
static void fill(int array[ ], int start, int end, int value)
static void fill(long array[ ], int start, int end, long value)
static void fill(short array[ ], int start, int end, short value)
static void fill(Object array[ ], int start, int end, Object value)
30-12-2017 68Lakshmi R, Asst. Professor, Dept. of ISE
69. The sort( ) method – version 1
• Sorts an array so that it is arranged in ascending order.
• It sorts an entire array
static void sort(byte array[ ])
static void sort(char array[ ])
static void sort(double array[ ])
static void sort(float array[ ])
static void sort(int array[ ])
static void sort(long array[ ])
static void sort(short array[ ])
static void sort(Object array[ ])
static <T> void sort(T array[ ], Comparator<? super T> c)
30-12-2017 69Lakshmi R, Asst. Professor, Dept. of ISE
70. The sort( ) method – version 2
• Enables you to specify a range within an array that you want to sort.
static void sort(byte array[ ], int start, int end)
static void sort(char array[ ], int start, int end)
static void sort(double array[ ], int start, int end)
static void sort(float array[ ], int start, int end)
static void sort(int array[ ], int start, int end)
static void sort(long array[ ], int start, int end)
static void sort(short array[ ], int start, int end)
static void sort(Object array[ ], int start, int end)
static <T> void sort(T array[ ], int start, int end, Comparator<? super T> c)
30-12-2017 70Lakshmi R, Asst. Professor, Dept. of ISE
71. Why Generic Collections?
• Generics add type safety to the Collection.
• Prior to generics, all collections stored references of type Object. This
allowed any type of reference to be stored in the collection.
• ArrayList list = new ArrayList(); - in this ArrayList example, any type of
reference can be stored.
• This can easily lead to errors.
• Consider the following example for pre-generic collection.
30-12-2017 71Lakshmi R, Asst. Professor, Dept. of ISE
72. // Pre-generics example that uses a collection.
import java.util.*;
class OldStyle {
public static void main(String args[]) {
ArrayList list = new ArrayList();
// These lines store strings, but any type of object
// can be stored. In old-style code, there is no
// convenient way to restrict the type of objects
stored
// in a collection
list.add("one");
list.add("two");
list.add("three");
list.add("four");
Iterator itr = list.iterator();
while(itr.hasNext()) {
// To retrieve an element, an explicit type
cast is needed
// because the collection stores only Object.
String str = (String) itr.next(); // explicit
cast needed here.
System.out.println(str + " is " +
str.length() + " chars long.");
}
}
}
30-12-2017 72Lakshmi R, Asst. Professor, Dept. of ISE
73. Why Generic Collections?
Problem with the preceding example:
1. it required that you, rather than the compiler, ensure that only
objects of the proper type be stored in a specific collection.
• For example, in the preceding example, list is clearly intended to store
Strings, but there is nothing that actually prevents another type of
reference from being added to the collection. For example, the compiler
will find nothing wrong with this line of code:
list.add(new Integer(100));
• Because list stores Object references, it can store a reference to Integer as
well as it can store a reference to String. However, if you intended list to hold
only strings, then the preceding statement would corrupt the collection.
30-12-2017 73Lakshmi R, Asst. Professor, Dept. of ISE
74. Why Generic Collections?
2. When you retrieve a reference from the collection, you must
manually cast that reference into the proper type.
3. Because Object can be cast into any type of object, it was possible
to cast a reference obtained from a collection into the wrong type.
For example, if the following statement were added to the
preceding example, it would still compile without error, but
generate a run-time exception when executed: Integer i = (Integer)
itr.next();
30-12-2017 74Lakshmi R, Asst. Professor, Dept. of ISE
75. Why Generic Collections?
• The addition of generics fundamentally improves the usability and
safety of collections because it
• Ensures that only references to objects of the proper type can actually be
stored in a collection. Thus, a collection will always contain references of a
known type.
• Eliminates the need to cast a reference retrieved from a collection. Instead, a
reference retrieved from a collection is automatically cast into the proper
type. This prevents run-time errors due to invalid casts and avoids an entire
category of errors.
• For example, ArrayList is now declared like this:
class ArrayList<E>
• Here, E is the type of element stored in the collection. Therefore, the
following declares an ArrayList for objects of type String:
ArrayList<String> list = new ArrayList<String>();30-12-2017 75Lakshmi R, Asst. Professor, Dept. of ISE
76. • Legacy Classes
• Dictionary
• Hashtable
• Properties
• Stack
• Vector
• Legacy Interface
• Enumeration
Legacy classes and interface
30-12-2017 76Lakshmi R, Asst. Professor, Dept. of ISE
77. 30-12-2017 Lakshmi R, Asst. Professor, Dept. of ISE 77
The Collection Algorithms
NOTE: Try to remember 5 to 6 algorithms of your choice