In this session you will learn:
Objects
Collections
Garbage Collection
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this core java training session, you will learn Collections - Maps. Topics covered in this session are:
• Collections – Maps
• Map Interface
• Map methods
• Mapuse
• Hashmap
• Treemap
• Utilities
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/
In this core java training session, you will learn Object Class. Topics covered in this session are:
• Object Class
• toString()
• equals()
• Hashing
• hashCode()
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/
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/
In this core java training session, you will learn Collections. Topics covered in this session are:
• Recap of Arrays
• Introduction to Collections API
• Lists – ArrayList, Vector, LinkedList
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/
In this core java training session, you will learn Collections – Sorting, Comparing. Topics covered in this session are:
• Recap of Arrays, ArrayLists
• Basically, there can be 2 operations that you would want to perform on Arrays/ArrayLists.. (and maybe, other collections)
• Search: Override equals() and hashCode().
• Sort: provide comparison logic – Two ways
• Comparable interface
• Comparator interface
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/
In this core java training session, you will learn Collections - Maps. Topics covered in this session are:
• Collections – Maps
• Map Interface
• Map methods
• Mapuse
• Hashmap
• Treemap
• Utilities
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/
In this core java training session, you will learn Object Class. Topics covered in this session are:
• Object Class
• toString()
• equals()
• Hashing
• hashCode()
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/
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/
In this core java training session, you will learn Collections. Topics covered in this session are:
• Recap of Arrays
• Introduction to Collections API
• Lists – ArrayList, Vector, LinkedList
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/
In this core java training session, you will learn Collections – Sorting, Comparing. Topics covered in this session are:
• Recap of Arrays, ArrayLists
• Basically, there can be 2 operations that you would want to perform on Arrays/ArrayLists.. (and maybe, other collections)
• Search: Override equals() and hashCode().
• Sort: provide comparison logic – Two ways
• Comparable interface
• Comparator interface
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/
In this session you will learn:
List – ArrayList, LinkedList
Set – HashSet, LinkedHashSet, TreeSet
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
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 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.
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
In this session you will learn:
Object class
Equality testing
Overriding equals()
Hashing
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
In this session you will learn:
List – ArrayList, LinkedList
Set – HashSet, LinkedHashSet, TreeSet
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
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 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.
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
In this session you will learn:
Object class
Equality testing
Overriding equals()
Hashing
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
Woxa Technologies have great industrial exoerts in java field they work on the live projects with students they are not teacher they are industrial trainer.
for more information 8471003400
ZeroSpace is a part of Woxa Technology where industrial trainer are ready to trained you.Take a demo class and choose your future in the programming field. We offer to learn in latest technology with live project which is demanding.
feel free to contact us-: 8471003400
Presentation related to the Java Hands-On Workshop I had conducted at MVJ College Of Engineering, Bengaluru.
The code examples and exercises related to the workshop can be found at https://github.com/arpoladia/java-hands-on-workshop.
Credits go to the book Thinking in Java by Bruce Eckel (http://www.mindviewinc.com/Books/TIJ4/). I strongly recommend all Java programmers to buy and read this book cover to cover.
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.).
WHAT ARE COLLECTIONS?
Collections store arbitrary objects in a structured manner. Types of collections available within the .NET Framework are:
ARRAYS
ADVANCED COLLECTIONS -
i) Non - Generics
ii) Generics
The Collection in Java is a framework that provides an architecture to store and manipulate the group of objects.
Java Collections can achieve all the operations that you perform on a data such as searching, sorting, insertion, manipulation, and deletion.
Java Collection means a single unit of objects. Java Collection framework provides many interfaces (Set, List, Queue, Deque) and classes (ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet).
core & advanced java classes in Mumbai
best core & advanced java classes in Mumbai with job assistance.
our features are:
expert guidance by it industry professionals
lowest fees of 5000
practical exposure to handle projects
well equiped lab
after course resume writing guidance
Mumbai Academics is Mumbai’s first dedicated Professional Training Center for Training with Spoke and hub model with Multiple verticles . The strong foundation of Mumbai Academics is laid by highly skilled and trained Professionals, carrying mission to provide industry level input to the freshers and highly skilled and trained Software Professionals/other professional to IT companies.
Generating the Server Response: HTTP Status CodesDeeptiJava
In this session you will learn:
Format of the HTTP response
How to set status codes
What the status codes are good for
Shortcut methods for redirection and error pages
A servlet that redirects users to browser-specific pages
A front end to various search engines
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
background and goals of generic programming
basics of generic classes = parameterized types
generic methods for general algorithms
inheritance rules for generic types
bounded type parameters
generic code and the Java Virtual Machine
restrictions and limitations
wildcard types and wildcard type capture
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
Flow Control
Exceptions
Assertions
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
Object Orientation
Overloading
Overriding
Constructor
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
Declarations and Access Control
Class Modifiers
Access Modifiers for Members
Non-Access Modifiers for Members
More Member Modifiers
Modifiers for Inner Classes
Class Declarations
Interface Declarations
Implementing an Interface
main() Method
Extra points to remember
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
Introduction to Databases
Advantages of Database Systems
Database Languages
Distributed Database
Relational Database Model
Structured Query Language (SQL)
Basic Ingredients of JDBC
Supplying Values for Prepared Statement Parameters
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
Threads
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
Inner Classes
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
Including Files at Request Time: jsp:include
Understanding jsp:include vs. <%@ include … %>
Options for Deploying Applets
Using jsp:plugin
Attributes of the jsp:plugin Element
Using JavaBeans Components in JSP Documents
Background: What Are Beans?
Using Beans: Basic Tasks
Setting Simple Bean Properties: jsp:setProperty
JSP Page That Uses StringBean(Code)
Conditional Bean Operations
Sharing Beans in Four Different Ways
Session-Based Sharing: Code
Application-Based Sharing: Code
Application-Based Sharing: Result
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
The Need for JSP
The JSP Framework
Benefits of JSP
Advantages of JSP Over Competing Technologies
Setting Up Your Environment
Invoking Java Code with JSP Scripting Elements
Uses of JSP Constructs
Design Strategy: Limit Java Code in JSP Pages
Basic Syntax
Types of Scripting Elements
JSP Expressions
JSP/Servlet Correspondence
Predefined Variables
Controlling the Structure of Generated Servlets
Purpose of the page Directive
The import Attribute
The contentType and page encoding Attributes
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
Streams
Using a stream
Manipulating the input data
Basics of the LineReader constructor
The LineWriter class
Flushing the buffer
PrintWriter
About FileDialogs
Typical FileDialog window
FileDialog constructors
Useful FileDialog methods I
Useful FileDialog methods II
Serialization
Conditions for serializability
Writing objects to a file
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
Introduction
Architecture
The Persistence Lifecycle
Getting Started
Relationships and Associations
Advanced Mapping Concepts
Hibernate Queries
Hibernate Transactions
Hibernate Extensions
Hibernate Cache
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
In this session you will learn:
Java History
Features of Java
Java Versions
Application Area
For more information, visit this link: https://www.mindsmapped.com/courses/software-development/online-java-training-for-beginners/
Let's dive deeper into the world of ODC! Ricardo Alves (OutSystems) will join us to tell all about the new Data Fabric. After that, Sezen de Bruijn (OutSystems) will get into the details on how to best design a sturdy architecture within ODC.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
3. Page 2Classification: Restricted
Objective
• Distinguish between correct and incorrect implementations of hashcode
methods.
• Make appropriate selection of collection classes/interfaces to suit
specified behavior requirements.
4. Page 3Classification: Restricted
hashcode()
• The hashcode value of an object gives a number which can be used to in
effect to index objects in a collection. A collection class can group its
objects by their hashcodes
• If two objects are equal as given the equals() method, their hashcodes
should be the same. So whenever equals() is overridden, hashcode() also
should be implemented
• The reverse is not required i.e. two objects that are not equal can have
the same hashcode. This makes sense, as it is not always possible to
ensure unique hashcodes. However, it is desirable to have distinct
hashcodes as this can improve performance.
Eg:
public int hashcode() { return (int)(value^5); }
5. Page 4Classification: Restricted
equals()
The equals method implements an equivalence relation:
• It is reflexive: for any reference value x, x.equals(x) should return true.
• It is symmetric: for any reference values x and y, x.equals(y) should
return true if and only if y.equals(x) returns true.
• It is transitive: for any reference values x, y, and z, if x.equals(y) returns
true and y.equals(z) returns true, then x.equals(z) should return true.
• It is consistent: for any reference values x and y, multiple invocations of
x.equals(y) consistently return true or consistently return false,
provided no information used in equals comparisons on the object is
modified.
• For any non-null reference value x, x.equals(null) should return false.
6. Page 5Classification: Restricted
Condition Required Not Required (But
Allowed)
x.equals(y)==true x.hashCode()==y.
hashCode()
x.hashCode()==y.
hashCode()
x.equals(y)==true
x.equals(y)==false No hashCode
requirements
x.hashCode()!=y.h
ashCode()
x.equals(y)==false
The hashCode() Contract
7. Page 6Classification: Restricted
Collection
• A collection is a data structure in which objects are stored
• The collections can grow and shrink dynamically
• The collection classes are in the java.util package
• Collections are of 3 kinds – Lists, Sets and Maps
• The Collection interface is the root of the collection hierarchy. Some
Collection implementations allow duplicate elements and others do not.
Some are ordered and others unordered.
• List and Set interfaces extend the Collection interface, but Map interface
does not
8. Page 7Classification: Restricted
The collections class and interface hierarchy
Collection
Set
List
SortedSet
HashSet LinkedHashSet TreeSet LinkedList Vector ArrayList
Indicates Implementation
Indicates Inheritance
10. Page 9Classification: Restricted
Set
• A Set is a collection that cannot contain duplicate elements.The Set
interface extends Collection and contains no methods other than those
inherited from Collection.
• It adds the restriction that duplicate elements are prohibited.
• The classes implementing Set interface are:
HashSet – Assures no duplicates, not ordered
TreeSet- No duplicates, gives elements in the sorted order
LinkedHashSet- No duplicates, insertion order or last accessed order is
maintained
11. Page 10Classification: Restricted
Example
Eg:
import java.util.*;
public class LinkTest {
public static void main(String args[]) {
LinkedHashSet linkSet=new LinkedHashSet();
linkSet.add("mango");
linkSet.add("apple");
linkSet.add(“mango”);
linkSet.add("banana");
Iterator i=linkSet.iterator();
while(i.hasNext())
System.out.println(i.next());
}
}
12. Page 11Classification: Restricted
List
• A List is an ordered Collection, elements are stored in the order in which
they were added
• Lists may contain duplicate elements.
• List allows positional access and search
• Classes implementing List interface are
ArrayList – Fast iteration and fast random access
Vector-Similar to ArrayList, slower than it, synchronized
LinkedList-Good for adding elements at the beginning or end, used for
implementing stacks and queues
13. Page 12Classification: Restricted
Example
import java.util.*;
public class ListTest {
public static void main(String args[]) {
ArrayList list=new ArrayList();
list.add("mango");
list.add("apple");
list.add(“mango”);
list.add("banana");
Iterator i=list.iterator();
while(i.hasNext())
System.out.println("Fruit is "+i.next());
}
}
14. Page 13Classification: Restricted
Map
• A Map is an object that maps keys to values.
• A map cannot contain duplicate keys: Each key can map to at most one
value.
Classes implementing Map interface are:
HashMap – Faster updates, allows one null key, many null values
Hashtable- Similar to HashMap, but slower, synchronized, does not allow
null keys and values
LinkedHashMap – Faster iterations, iterates by insertion or last accessed
order. Allows one null key and many null values
TreeMap- A sorted map, in natural order of keys
15. Page 14Classification: Restricted
Example
import java.util.*;
class TreeMapDemo {
public static void main(String args[])
{
TreeMap tm=new TreeMap();
tm.put("India",new Integer(100));
tm.put("USA",new Integer(7));
tm.put("Pakistan",new Integer(2));
System.out.println(tm);
}
}
16. Page 15Classification: Restricted
Collection Interface Concrete Implementation Classes
Class Map Set List Ordered Sorted
HashMap X No No
Hashtable X No No
TreeMap X Sorted By natural order or
custom comparison
rules
LinkedHashMap X By insertion order
or last access order
No
HashSet X No No
TreeSet X Sorted By natural order or
custom comparison
rules
LinkedHashSet X By insertion order
or last access order
No
ArrayList X By index No
Vector X By index No
LinkedList X By index No
17. Page 16Classification: Restricted
Extra Points to Remember
• It is incorrect to involve a random number directly when computing the
hashcode, because it would not return the same hashcode for multiple
invocations of the method
• Hashcode of a null element is defined as zero
• StringBuffer class does not override equals() and hence inherits the default
implementation given in Object class
• For wrapper classes and String class, equals() method returns false if the
argument type is different from that of the invoking object
Eg: Integer i=new Integer(7);
Float f=new Float(7);
if(i.equals(f)) // gives false
System.out.println(“Equal”);
18. Page 17Classification: Restricted
Objectives
• State the behavior that is guaranteed by the garbage collection system.
• Write code that explicitly makes objects eligible for garbage collection.
• Recognize the point in a piece of source code at which an object
becomes eligible for garbage collection.
19. Page 18Classification: Restricted
Garbage Collection
• Garbage collection refers to the automatic memory management
provided by Java
• The Java runtime environment has a garbage collector that periodically
frees the memory used by objects that are no longer needed.
• The garbage collector runs in a low priority thread and it’s
implementation is specific to the JVM
• An object is considered eligible for garbage collection when no live
thread can reach it
20. Page 19Classification: Restricted
Requesting for Garbage Collection
• Garbage collection cannot be forced and there is no guarantee as to
when the garbage collector thread will run
• You can request for garbage collection to be initiated, but the request
may or may not be granted
• To request for garbage collection, you can call any of these methods
• System.gc()
• Runtime.getRuntime().gc()
• If available memory is too low, the garbage collector will surely run
before it throws OutOfMemoryException
21. Page 20Classification: Restricted
Making objects eligible for GC
• An object can become eligible for Garbage Collection in different ways
Objects which are created locally in a method are eligible when the
method returns, unless they are exported out of the method (returned
or thrown as an exception)
If the reference variable that refers to the object is set to null, it
becomes eligible
If the reference variable that refers to the object is made to refer to
some other object, it becomes eligible
Objects which refer to each other can still be eligible, if no live thread
can access either of them
22. Page 21Classification: Restricted
Examples
• Eg: // Objects created in a method
public class Test
{ public static void main(String args[]) {
String s=getDateString();
System.out.println(“Date string is “+s);
}
public String getDateString() {
Date date=new Date();
return date.toString();
}
}
/* The object date is eligible for garbage collection after the method
returns */
23. Page 22Classification: Restricted
Examples
• Eg: // Reassigning reference variables
public class TestGC
{ public static void main(String [] args) {
Object a = new Integer(7);
Object b = new StringBuffer("Java");
a = b;
b = null;
}
}
/* Here only the Integer object is eligible for collection
24. Page 23Classification: Restricted
Object Finalization
• The finalize() method defined in the class Object is inherited by all classes.
protected void finalize() throws Throwable
• This method is called just before the object is garbage collected, so the
object can perform any cleanup action here
• The finalize() method will be invoked only once in the lifetime of an object
• You can write code in the finalize() method which can prevent the object
from being garbage collected.
25. Page 24Classification: Restricted
Extra points to remember…
• The garbage collection algorithm used is specific to each JVM
• You can make an object uneligible for garbage collection, from its finalize()
method. But the garbage collector will not run finalize() for this object again
• A finalizer can catch and throw exceptions
• Any exception thrown but not caught in the finalize() method is ignored by
the garbage collector
• It cannot be guaranteed that the garbage collector will run, so finalize()
method may never be called
• There is no guarantee on the order in which objects will be garbage collected