Fundamental language mechanisms
|
|
- Janice Tyler
- 5 years ago
- Views:
Transcription
1 Java Fundamentals
2 Fundamental language mechanisms
3 The exception mechanism
4 What are exceptions? Exceptions are exceptional events in the execution of a program Depending on how grave the event is, the program might or might not recover From a programming standpoint, exceptions are also classes through which such events are represented In Java exceptions are objects
5 Why use exceptions? Separation of the error handling code Cleaner program structure Possibility to easily trace the cause of the event (propagation through the call stack) In some cases, possibility to continue execution (after handling the unpredicted event) Easier management of rare resources (e.g. files, connections)
6 The old approach 1. if(!db_connect()){ 2. //return error 3. } 4. int error_code = do_db_op(); 5. switch(error_code){ 6. //handle error 7. } 8. //etc.
7 The new approach 1. try { 2. conn = DriverManager.getConnection( ); 3. stmt = conn.createstatement(); 4. int result = stmt.executeupdate( "); 5. catch (SQLException ex) { 6. //handle exception 7. }
8 Types exceptions in Java Checked exceptions are exceptions from which the program can and should recover (e.g. a file is not found) must be handled, either by catching or throwing Errors are exceptional events from outside the application, from which it cannot usually recover (e.g. a hardware component fails)
9 Types exceptions in Java Runtime exceptions are generated within the application but cannot usually be recovered from (i.e. a null pointer is sent to a constructor) not necessarily handled
10 Exception handling try - a block defining the code to be checked catch - a block treating an exception there can be multiple catch blocks catch blocks for an exception are selected sequentially catch blocks should be defined from the specific to the general finally - a block executed whether exceptions are raised or not
11 Exception handling 1. try { 2. //code 3. } catch (Exception1 ex) { 4. //handle first type of exception 5. } catch (Exception2 ex) { 6. //handle second type of exception 7. // 8. } finally { 9. //execute regardless if exceptions were thrown 10. }
12 Reading exception output Call stack Stack trace
13 Handling resources Finally blocks Always dispose of resources in finally Avoid nesting try blocks in finally Try with resources (only in Java 7)
14 Handling resources 1. try { 2. writer = new FileWriter(f); 3. } catch (IOException ex) { 4. ex.printstacktrace(); 5. } 6. finally{ 7. if (writer!=null) 8. writer.close(); 9. }
15 Throwing exceptions Exception forwarding Checked exceptions should be handled by the code which can restore the normal flow of the application The throws clause Throwing exceptions The throw instruction Custom exception classes
16 Function throwing an exception 1. public int checkaccount() throws IOException{ 2. // 3. } Page 16 7/22/2011
17 Stream based I/O
18 Why streams Standardized method of access Destinations or sources have the same interface Possibility of piping Hides complexity of operations
19 Stream piping Stream piping allows for the chaining of streams Byte, character and buffered streams can be chained to hide complexity
20 Piped streams 1. FileWriter writer = null; 2. PrintWriter out; 3. // 4. writer = new FileWriter(f); 5. out = new PrintWriter(writer); 6. out.println("sometext");
21 Available streams Byte, character and buffered streams Standard input System.in System.out System.err Console
22 Using buffered streams 1. BufferedReader in = null; 2. PrintWriter out = null; 3. in = new BufferedReader(new FileReader("test.in")); 4. out = new PrintWriter (new FileWriter("test.out")); 5. String l; 6. while ((l = in.readline())!= null) { 7. out.write(l); 8. }
23 Scanning and formatting Scanners extract tokens from input data tokens can be of string type, but also primitive types Formatters the format method outputs data according to a format string ava/util/formatter.html#syntax
24 Using a scanner 1. Scanner scanner = null; 2. scanner = new Scanner(new BufferedReader(new FileReader("numbers.txt"))); 3. while (scanner.hasnext()) { 4. if (scanner.hasnextint()) { 5. System.out.println(scanner.nextInt()); 6. } else { 7. scanner.next(); 8. } 9. }
25 Other streams Data streams Can read typed values from a file Reading ends based on an EOFException, not a return value
26 Other streams Object streams Objects can be written and read from a file as long as they are serializable The possibility to serialize is marked through the Serialize interface Objects which contain references to local resources(e.g. a connection) are not serializable
27 Using object strems 1. ObjectOutputStream penguinstream = null; 2. ObjectInputStream clonestream = null; 3. // 4. penguinstream = new ObjectOutputStream(new FileOutputStream("penguins.db")); 5. penguinstream.writeobject(somepenguin); 6. clonestream = new ObjectInputStream(new FileInputStream("penguins.db")); 7. Penguin someclone = (Penguin) clonestream.readobject();
28 Generics
29 What are generics? Syntactic mechanism Allow for the definition of generic code
30 Why use generics It is preferable to detect errors at compile time Code using Object can be confusing and difficult to maintain Easier implementation of containers and thus collections
31 A simple container 1. public class Nest { 2. public Object content; 3. public void addcontent(object content){ 4. this.content = content; 5. } 6. public Object getcontent(){ 7. return content; 8. } 9. }
32 The problem with containers 1. Duckling smallduck = new Duckling("quacky"); 2. Nest nest = new Nest(); 3. nest.addcontent(smallduck); 4. //every time we want to access it we must cast it 5. //and know what the right type is 6. Duckling copyduck = (Duckling) nest.getcontent();
33 Using generics Generics define a template Generic types are replaced with actual types Using an incompatible type generates compile time errors While Box<String> and Box<Integer> are incompatible at compile time, they have the same type at runtime
34 A generic nest 1. public class Nest<T> { 2. public T content; 3. public void addcontent(t content){ 4. this.content = content; 5. } 6. public T getcontent(){ 7. return content; 8. } 9. }
35 The advantage of a generic nest 1. Duckling smallduck = new Duckling("quacky"); 2. Nest<Duckling> nest = new Nest<Duckling>(); 3. nest.addcontent(smallduck); 4. //no more casting to Duckling 5. Duckling copyduck = nest.getcontent();
36 What can generics be used for? Generic functions Generic classes Generic constructors
37 More generics Type rewriting Generic bounded types Upper bounded Lower bounded Generic wildcards
38 Using type binding 1. public class Nest<T extends Flying> { 2. // 3. } 4. //the nest can contain only children of Flying
39 Collections
40 What are collections? A collection is a group of single elements of a certain type Elements can be considered containers for a single object Initially collections contained objects of Object type Generic collections are collections with elements of a specified type
41 Why use collections? Arrays are difficult to use fixed length space inefficient it is difficult to delete elements it is difficult to represent higher complexity structures (e.g. a queue) Collections have evolved from design patterns used on arrays
42 Declaring a collection 1. Animal lion = new Animal("lion"); 2. Animal dog = new Animal("dog"); 3. ArrayList list = new ArrayList(); 4. list.add(lion); 5. list.add(dog);
43 Iterating a collection with foreach 1. for (Object item : list) { 2. Animal currentanimal = (Animal)item; 3. currentanimal.makesound(); 4. }
44 A generic collection 1. Animal lion = new Animal("lion"); 2. Animal dog = new Animal("dog"); 3. List<Animal> list = new ArrayList<Animal>(); 4. list.add(lion); 5. list.add(dog); 6. for (Animal item : list) { 7. item.makesound(); 8. }
45 The Collection framework Interfaces abstract types outlining the various categories of collections Implementations actual implementations of the interfaces user defined implementations can be added Algorithms polymorphic implementations of useful collection operations such as sorting
46 Core collection interfaces Collection Set SortedSet List Queue Map SortedMap
47 Iterators Collections can be easily manipulated with the foreach language construct Iterators are special objects used to traverse a collection Iterator methods next hasnext remove Iterators are the only safe way to delete elements from collections
48 Using an iterator 1. for (Iterator<Road> it = roads.iterator(); 2. it.hasnext();) { 3. Road road = it.next(); 4. if (road.name.equals("dacia")) { 5. it.remove(); 6. continue; 7. } 8. System.out.println(road.name); 9. }
49 Set implementations sets contain unique elements general implementations HashSet is a faster implementation but does not support ordering; has a fixed initial capacity which affects iteration time TreeSet also implements sorted set, although it is slower LinkedHashSet is a n intermediary implementation with support for insert ordered iteration
50 Set implementations special purpose implementations EnumSet is a high performance implementation usable with enum types CopyOnWriteArraySet implements a set which makes a new copy for any operation which modifies it (insert,delete,update); this is the only intrinsically thread safe set
51 List implementations Lists are ordered collections and as such support positional operations Lists can contain duplicate elements General purpose implementations ArrayList supplies fast, constant time positional access LinkedList is a list optimized for deletion and full iteration Special purpose implementations CopyOnWriteArrayList implements a list which makes a new copy for any operation which
52 Queue implementations Queues are collections which have added operations A queue can be treated as the titular structure or as a simple collection
53 Queue implementations Generic implementations PriorityQueue is an implementation providing ordering either based on a Comparator LinkedList is also an implementation of Qu Concurrent implementations LinkedBlockingQueue,ArrayBlockingQueue,Prior ityblockingqueue,delayqueue,synchronousque ue
54 Map implementations Maps are collections of key/value pairs General purpose implementations HashMap provides maximum performance but is not sorted TreeMap provides operations specific to sorted maps LinkedHashMap provides key access ordering (pairs are ordered in according to the latest access to their key)
55 Map implementations Special purpose implementations EnumMap is a high performance implementation for use with enum keys WeakHashMap is an implementation optimized for garbage collection keys are stored as weak references pairs are collected when no longer referenced from outside the map IdentityHashMap maintains knowledge of which objects have been seen and which have not Concurrent maps ConcurrentMap is a map optimized for
56 Using a map 1. Map<String,String> dictionary = 2. new HashMap<String, String>(3); 3. dictionary.put("cat", "cat definition"); 4. dictionary.put("dog", "dog definition"); 5. dictionary.put("penguin", "penguin definition"); 6. dictionary.put("duck", "duck definition"); 7. for (Entry<String,String> item : 8. dictionary.entryset()) { 9. System.out.println("Definition for " item.getkey() + " is " + item.getvalue()); 11. }
57 Wrapper implementations Wrapper implementations use a specified collection for their operations but add functionality synchronized versions of the collections e.g. Collection.synchronizedList unmodifiable versions of the collections e.g. Collection.unmodifiableList
58 What implementations to use? Commonly used implementations: ArrayList for List HashSet for Set LinkedList for Queue HashMap for Map
59 Algorithms Reusable algorithms static methods polymorphic Found in the Collections class
60 Available algorithms Sorting sort Shuffling shuffle Common operations reverse fill copy swap addall
61 Available algorithms Searching binarysearch Composition frequency disjoint Extreme values min max
62 Using algorithms Most algorithms assume the existence of a way of comparing objects A class which wishes to be compared can do so in two ways Via a defauld comparator Via a custom comparator
63 Using the default comparator The default comparator is used by implementing the Comparable interface which forces a class to implement compareto compareto returns a numeric value reflecting ordering
64 A comparable class 1. public class Penguin implements 2. Comparable<Penguin>{ 3. String name; 4. int speed; 5. // 6. public int compareto(penguin o) { 7. return this.speed - o.speed; 8. } }
65 Sorting a collection 1. List<Integer> list = new ArrayList<Integer>(); 2. //add the values 3. Collections.sort(list); 4. for (Integer item : list) { 5. //process each item 6. }
66 Using a custom comparator A custom comparator is a separate class It must implement the generic Comparator<ClassToBeCompared> interface which forces the implementation of the compare method The compare method returns a similar result to compareto(and can in fact use it)
67 A custom comparator 1. public class PenguinComparator implements 2. Comparator<Penguin>{ 3. public int compare(penguin o1, Penguin o2) { 4. return o1.name.compareto(o2.name); 5. } 6. }
68 Searching the collection 1. //binary search needs a form of comparisson 2. int index = Collections.binarySearch(penguinList, new Penguin("A", 0), new PenguinComparator());
Java 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 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 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 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 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 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 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 informationChapter 10. File I/O. Copyright 2016 Pearson Inc. All rights reserved.
Chapter 10 File I/O Copyright 2016 Pearson Inc. All rights reserved. Streams A stream is an object that enables the flow of data between a program and some I/O device or file If the data flows into a program,
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 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 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 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 informationA Quick Tour p. 1 Getting Started p. 1 Variables p. 3 Comments in Code p. 6 Named Constants p. 6 Unicode Characters p. 8 Flow of Control p.
A Quick Tour p. 1 Getting Started p. 1 Variables p. 3 Comments in Code p. 6 Named Constants p. 6 Unicode Characters p. 8 Flow of Control p. 9 Classes and Objects p. 11 Creating Objects p. 12 Static or
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 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 informationSoftware 1 with Java. Recitation No. 6 (Collections)
Software 1 with Java Recitation No. 6 (Collections) Java Collections Framework Collection: a group of elements Interface Based Design: Java Collections Framework Interfaces Implementations Algorithms 2
More informationCS 251 Intermediate Programming Java I/O Streams
CS 251 Intermediate Programming Java I/O Streams Brooke Chenoweth University of New Mexico Spring 2018 Basic Input/Output I/O Streams mostly in java.io package File I/O mostly in java.nio.file package
More informationCOURSE 4 PROGRAMMING III OOP. JAVA LANGUAGE
COURSE 4 PROGRAMMING III OOP. JAVA LANGUAGE PREVIOUS COURSE CONTENT Inheritance Abstract classes Interfaces instanceof operator Nested classes Enumerations COUSE CONTENT Collections List Map Set Aggregate
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 informationDOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS
Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully
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 informationTraining topic: OCPJP (Oracle certified professional Java programmer) or SCJP (Sun certified Java programmer) Content and Objectives
Training topic: OCPJP (Oracle certified professional Java programmer) or SCJP (Sun certified Java programmer) Content and Objectives 1 Table of content TABLE OF CONTENT... 2 1. ABOUT OCPJP SCJP... 4 2.
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 informationSyllabus & Curriculum for Certificate Course in Java. CALL: , for Queries
1 CONTENTS 1. Introduction to Java 2. Holding Data 3. Controllin g the f l o w 4. Object Oriented Programming Concepts 5. Inheritance & Packaging 6. Handling Error/Exceptions 7. Handling Strings 8. Threads
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 informationCOMP-202: Foundations of Programming. Lecture 12: Linked List, and File I/O Sandeep Manjanna, Summer 2015
COMP-202: Foundations of Programming Lecture 12: Linked List, and File I/O Sandeep Manjanna, Summer 2015 Announcements Assignment 4 is posted and Due on 29 th of June at 11:30 pm. Course Evaluations due
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 informationJava Input/Output. 11 April 2013 OSU CSE 1
Java Input/Output 11 April 2013 OSU CSE 1 Overview The Java I/O (Input/Output) package java.io contains a group of interfaces and classes similar to the OSU CSE components SimpleReader and SimpleWriter
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 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 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 informationSoftware 1 with Java. Java Collections Framework. Collection Interfaces. Online Resources. The Collection Interface
Java Collections Framework Collection: a group of elements Based Design: Software 1 with Java Java Collections Framework s s Algorithms Recitation No. 6 (Collections) 2 Collection s Online Resources Collection
More informationComplete Java Contents
Complete Java Contents Duration: 60 Hours (2.5 Months) Core Java (Duration: 25 Hours (1 Month)) Java Introduction Java Versions Java Features Downloading and Installing Java Setup Java Environment Developing
More informationApplication Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started
Application Development in JAVA Duration Lecture: Specialization x Hours Core Java (J2SE) & Advance Java (J2EE) Detailed Module Part I: Core Java (J2SE) Getting Started What is Java all about? Features
More informationJAVA. 1. Introduction to JAVA
JAVA 1. Introduction to JAVA History of Java Difference between Java and other programming languages. Features of Java Working of Java Language Fundamentals o Tokens o Identifiers o Literals o Keywords
More informationLecture 6 Collections
Lecture 6 Collections Concept A collection is a data structure actually, an object to hold other objects, which let you store and organize objects in useful ways for efficient access Check out the java.util
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 informationTony Valderrama, SIPB IAP 2010
Today Java API java.util java.io More OOP Generics Enum.jar files JNI Q & A Announcements Course website: http://sipb.mit.edu/iap/java/ Email: sipb-iap-java@mit.edu package java.io Images from the Java
More informationCollections, Maps and Generics
Collections API Collections, Maps and Generics You've already used ArrayList for exercises from the previous semester, but ArrayList is just one part of much larger Collections API that Java provides.
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014 Name: This exam consists of 5 problems on the following 6 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet
More informationHST 952. Computing for Biomedical Scientists Lecture 8
Harvard-MIT Division of Health Sciences and Technology HST.952: Computing for Biomedical Scientists HST 952 Computing for Biomedical Scientists Lecture 8 Outline Vectors Streams, Input, and Output in Java
More informationIntroduction Unit 4: Input, output and exceptions
Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Introduction Unit 4: Input, output and exceptions 1 1.
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 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 informationActive Learning: Streams
Lecture 29 Active Learning: Streams The Logger Application 2 1 Goals Using the framework of the Logger application, we are going to explore three ways to read and write data using Java streams: 1. as text
More informationCSCI Object Oriented Design: Java Review Execution, I/O and New Features George Blankenship. Java Review: Execution, IO & Java 5
CSCI 6234 Object Oriented Design: Java Review Execution, I/O and New Features George Blankenship George Blankenship 1 Java Topics Running Java programs Stream I/O New features George Blankenship 2 Running
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 informationCore Java - SCJP. Q2Technologies, Rajajinagar. Course content
Core Java - SCJP Course content NOTE: For exam objectives refer to the SCJP 1.6 objectives. 1. Declarations and Access Control Java Refresher Identifiers & JavaBeans Legal Identifiers. Sun's Java Code
More informationCollections (Collection Framework) Sang Shin Java Technology Architect Sun Microsystems, Inc.
Collections (Collection Framework) Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com www.javapassion.com 2 Disclaimer & Acknowledgments Even though Sang Shin is a full-time employee
More informationSoftware Development & Education Center. Java Platform, Standard Edition 7 (JSE 7)
Software Development & Education Center Java Platform, Standard Edition 7 (JSE 7) Detailed Curriculum Getting Started What Is the Java Technology? Primary Goals of the Java Technology The Java Virtual
More informationGenerics Collection Framework
Generics Collection Framework Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 Generics
More informationVALLIAMMAI ENGINEERING COLLEGE
VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED
More informationCONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13
CONTENTS Chapter 1 Getting Started with Java SE 6 1 Introduction of Java SE 6... 3 Desktop Improvements... 3 Core Improvements... 4 Getting and Installing Java... 5 A Simple Java Program... 10 Compiling
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
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 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 informationתוכנה 1 מבני נתונים גנריים
תוכנה 1 מבני נתונים גנריים תרגול 8 Java Collections Framework Collection: a group of elements Interface Based Design: Java Collections Framework Interfaces Implementations Algorithms 2 Online Resources
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 informationF1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept
F1 A Java program Ch 1 in PPIJ Introduction to the course The computer and its workings The algorithm concept The structure of a Java program Classes and methods Variables Program statements Comments Naming
More informationData Structures and Abstractions with Java
Global edition Data Structures and Abstractions with Java Fourth edition Frank M. Carrano Timothy M. Henry Data Structures and Abstractions with Java TM Fourth Edition Global Edition Frank M. Carrano University
More informationPIC 20A Collections and Data Structures
PIC 20A Collections and Data Structures Ernest Ryu UCLA Mathematics Last edited: March 14, 2018 Introductory example How do you write a phone book program? Some programmers may yell hash table! and write
More informationC17: File I/O and Exception Handling
CISC 3120 C17: File I/O and Exception Handling Hui Chen Department of Computer & Information Science CUNY Brooklyn College 10/24/2017 CUNY Brooklyn College 1 Outline Recap and issues Exception Handling
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 informationJAVA MOCK TEST JAVA MOCK TEST IV
http://www.tutorialspoint.com JAVA MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your
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 informationSri Vidya College of Engineering & Technology Question Bank
1. What is exception? UNIT III EXCEPTION HANDLING AND I/O Part A Question Bank An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program s instructions.
More informationJava Collections. Readings and References. Collections Framework. Java 2 Collections. References. CSE 403, Winter 2003 Software Engineering
Readings and References Java Collections References» "Collections", Java tutorial» http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Winter 2003 Software Engineering http://www.cs.washington.edu/education/courses/403/03wi/
More informationThe name of the Show What will you enjoy learning?
The Day of celebration The name of the Show What will you enjoy learning? 1 The tale of programming A walk down the memory lane! 1) Programming - How did it all start and evolve? 2) What should you learn
More informationOutline. CS6202 Java Generics 1
Outline Overview Subtyping and Wildcard Comparison and Bounds Declaration and Erasure Reification and Reflection Collections Iterator, Iterable, Collection Set, Queues, List, Maps Design Patterns Other
More informationTable of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...
Table of Contents Chapter 1 Getting Started with Java SE 7 1 Introduction of Java SE 7... 2 Exploring the Features of Java... 3 Exploring Features of Java SE 7... 4 Introducing Java Environment... 5 Explaining
More informationCS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University
CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Files Two types: Text file and Binary file Text file (ASCII file) The file data contains only ASCII values
More informationTutorial #11 SFWR ENG / COMP SCI 2S03. Interfaces and Java Collections. Week of November 17, 2014
Tutorial #11 SFWR ENG / COMP SCI 2S03 Interfaces and Java Collections Week of November 17, 2014 Interfaces An interface defines a specification or contract that a class must meet to be defined as an instance
More informationJava How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.
Java How to Program, 9/e Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Data stored in variables and arrays is temporary It s lost when a local variable goes out of scope or when
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 informationJava: exceptions and genericity
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: exceptions and genericity Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Exceptions Exceptions
More informationTopic 10: The Java Collections Framework (and Iterators)
Topic 10: The Java Collections Framework (and Iterators) A set of interfaces and classes to help manage collections of data. Why study the Collections Framework? very useful in many different kinds of
More informationCONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17
List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code
More informationBasic I/O - Stream. Java.io (stream based IO) Java.nio(Buffer and channel-based IO)
I/O and Scannar Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 I/O operations Three steps:
More informationCORE JAVA TRAINING COURSE CONTENT
CORE JAVA TRAINING COURSE CONTENT SECTION 1 : INTRODUCTION Introduction about Programming Language Paradigms Why Java? Flavors of Java. Java Designing Goal. Role of Java Programmer in Industry Features
More information15CS45 : OBJECT ORIENTED CONCEPTS
15CS45 : OBJECT ORIENTED CONCEPTS QUESTION BANK: What do you know about Java? What are the supported platforms by Java Programming Language? List any five features of Java? Why is Java Architectural Neutral?
More informationContents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix
PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring
More informationCSE 143 Au04 Midterm 2 Sample Solution Page 1 of 7
CSE 143 Au04 Midterm 2 Sample Solution Page 1 of 7 Reference information about some standard Java library classes appears on the last pages of the test. You can tear off these pages for easier reference
More informationBuilding Java Programs
Building Java Programs A Back to Basics Approach Stuart Reges I Marty Stepp University ofwashington Preface 3 Chapter 1 Introduction to Java Programming 25 1.1 Basic Computing Concepts 26 Why Programming?
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 informationImplementation. (Mapping to Java) Jörg Kienzle & Alfred Strohmeier. COMP-533 Implementation
Implementation (Mapping to Java) Jörg Kienzle & Alfred Strohmeier COMP-533 Implementation Datatype Enumeration Class Attribute Association Inheritance Method Visibility Collections Overview 2 Data Type
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 informationContents Chapter 1 Introduction to Programming and the Java Language
Chapter 1 Introduction to Programming and the Java Language 1.1 Basic Computer Concepts 5 1.1.1 Hardware 5 1.1.2 Operating Systems 8 1.1.3 Application Software 9 1.1.4 Computer Networks and the Internet
More informationCertification In Java Language Course Course Content
Introduction Of Java * What Is Java? * How To Get Java * A First Java Program * Compiling And Interpreting Applications * The JDK Directory Structure Certification In Java Language Course Course Content
More informationLecture 11.1 I/O Streams
21/04/2014 Ebtsam AbdelHakam 1 OBJECT ORIENTED PROGRAMMING Lecture 11.1 I/O Streams 21/04/2014 Ebtsam AbdelHakam 2 Outline I/O Basics Streams Reading characters and string 21/04/2014 Ebtsam AbdelHakam
More informationGenerics. IRS W-9 Form
Generics IRS W-9 Form Generics Generic class and methods. BNF notation Syntax Non-parametrized class: < class declaration > ::= "class" < identifier > ["extends" < type >] ["implements" < type list >]
More informationLearn Java/J2EE Basic to Advance level by Swadeep Mohanty
Basics of Java Java - What, Where and Why? History and Features of Java Internals of Java Program Difference between JDK,JRE and JVM Internal Details of JVM Variable and Data Type OOPS Conecpts Advantage
More informationCSC 1351: Final. The code compiles, but when it runs it throws a ArrayIndexOutOfBoundsException
VERSION A CSC 1351: Final Name: 1 Interfaces, Classes and Inheritance 2 Basic Data Types (arrays, lists, stacks, queues, trees,...) 2.1 Does the following code compile? If it does not, how can it be fixed?
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 informationIT101. File Input and Output
IT101 File Input and Output IO Streams A stream is a communication channel that a program has with the outside world. It is used to transfer data items in succession. An Input/Output (I/O) Stream represents
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 information"Charting the Course... Java Programming Language. Course Summary
Course Summary Description This course emphasizes becoming productive quickly as a Java application developer. This course quickly covers the Java language syntax and then moves into the object-oriented
More informationTopic #9: Collections. Readings and References. Collections. Collection Interface. Java Collections CSE142 A-1
Topic #9: Collections CSE 413, Autumn 2004 Programming Languages http://www.cs.washington.edu/education/courses/413/04au/ If S is a subtype of T, what is S permitted to do with the methods of T? Typing
More informationCOMP-202: Foundations of Programming. Lecture 22: File I/O Jackie Cheung, Winter 2015
COMP-202: Foundations of Programming Lecture 22: File I/O Jackie Cheung, Winter 2015 Announcements Assignment 5 due Tue Mar 31 at 11:59pm Quiz 6 due Tue Apr 7 at 11:59pm 2 Review 1. What is a graph? How
More informationJava HashMap Interview Questions
Java HashMap Interview Questions codespaghetti.com/java-hashmap-interview-questions/ HashMap Java HashMap Interview Questions, Algorithms and Programs. Table of Contents: CHAPTER 1: Java HashMap Interview
More informationStreams and File I/O
Walter Savitch Frank M. Carrano Streams and File I/O Chapter 10 Objectives Describe the concept of an I/O stream Explain the difference between text and binary files Save data, including objects, in a
More information