when to use ArrayList and when to use HashMap 1 Answer(s) 3 years and 8 months ago
Posted in : Java Interview Questions
View Answers
October 2, 2009 at 12:25 PM
When your application demands saving the objects then ArrayList can be used. But if you need to retrieve the objects more often then HashMap is preferable.This is the basic diff. Aray-List is fast for storing and hashmap is fast for retrieving. If your application needs both storing and retrieving at same no. of times then u can Arraylist for storing and hashmap for the latter purpose.
.When to use detached criteria in hibernate?
.When to use detached criteria in hibernate? When to use detached criteria in hibernate?
Detached Criteria query is a facility provide by
Hibernate to write criteria queries in detached
mode, where hibernate session
hashmap
hashmap write a program that shows the use of Hashmap class
ArrayList
.
An ArrayList allows use of iterators.
UseArrayListwhen there will be a large variation...).
To use a primitive type in an ArrayList,
put it inside an object (eg, to save...
to create an ArrayList with a size that it will commonly be when full
Java Hashmap Sorting - Java Beginners
Java Hashmap Sorting
I have a sorting issue with a Hashmap. My constraint is that I MUST use the Hashmap and work with existing code. I do a database query and place the results in a Hashmap. When I iterate thru the Hashmap
HashMap in Java
:
HashMap map = new HashMap();
Map map = new HashMap();
If you use Map than while implementing there will be no code compatibility problem but when you use...HashMap class is used to implement Map interface. The value of HashMap
ArrayList
.
An ArrayList allows use of iterators.
UseArrayListwhen there will be a large variation...).
To use a primitive type in an ArrayList,
put it inside an object (eg, to save...
to create an ArrayList with a size that it will commonly be when full
Java HashMap - Java Tutorials
keys to value means it associate value to
unique keys which you use... by using it's key.
When no element exists in the invoking Map, many methods... when an object is incompatible with the
elements in a map
to use ArrayList in the place of Vector
to useArrayList in the place of Vector public Enumeration getInterfaces()
{
ISCMetaType currentType = this;
ArrayList allInterfaces = new ArrayList();
while( currentType != null
to use ArrayList in the place of Vector
to useArrayList in the place of Vector public Enumeration getInterfaces()
{
ISCMetaType currentType = this;
ArrayList allInterfaces = new ArrayList();
while( currentType != null
Implementing a SoftReference based HashMap - Java Tutorial
into a normal HashMap, you
can easily run out of memory when you access many... to use
for the HashMap values than a WeakReference, but the default JDK...Implementing a SoftReference based HashMap
2001-03-28 The Java Specialists
JSP JSTL c:when tag
JSP JSTL c:when tag
In this section, you will learn how to use the jstl when tag in jsp.
Basically, the choose, when, and otherwise tags can
Can ArrayList accept an ImageIcon >>????
Can ArrayList accept an ImageIcon >>???? haw can create ArrayList witch can accept Image ..mean when i use add() method, instead item let me add image to the ArrayList in run time .{should be the program using GUI
arraylist
% *(noOfYearService/2).
Store each employee information in different arrayList depending on his...). Below is a sample format of a report when a user chooses to display a report
Java arraylist generics example and arraylist generic list
feature of java 5.
When the ArrayList is generalized for a specific data... data type element.
Example of Java Generic Arraylist
import... static void main(String[] args) {
List list=new ArrayList
arraylist
arraylist create a class employee having instance variable
id,name,age,salary.now , when u run the program it must be ask u to
1.add employee
2.view employee
3.exit
if u enter value other than 1,2,3 program should say
ArrayList<E> ArrayListwhen there will be a large variation in the amount
of data that you would... in an ArrayList,
put it inside an object or use of the wrapper classes (eg... faster
to create an ArrayList with a size that it will commonly be when full
how to use a session.removeAttribute - JSP-Servlet
how to use a session.removeAttribute Dear Sir,
I am... to send a mail to all employees when i upload a file.I am storing a different matters in a arraylist,and that arrylist am storing in a session.My probs
arraylist of an arraylist arraylist of an arraylist Can anyone suggest me how to usearraylist of an arraylist?? how to put data into it and get data from it???? becoz i want to make rows and column dynamic which can grow as per requirement?????/ plz
ArrayList (non-generic)
.
Automatic expansion. UseArrayListwhen there will be a large variation... of a ArrayList is that it
holds only objects and not primitive types (eg, int).
To use... from an ArrayListUse either a for loop with an integer index to get all
Java HashMap iterator and example
Java HashMap Iterator is an interface. It keeps the data in the key and value form.
It is implemented by HashMap. hashMap doesnot have iterator
method.
So use the entrySet() method to get the data in Set object form.
Set's all
use of package concepts use of package concepts i m getting error when i use .* method to access all package files. when i use this through another method like... want to use packagename.* methhod.
please solve the problem.
i just start
how to use an editable combobox
how to use an editable combobox Hello Everyone!!!!!!!!
I have a jcombo box with certain values and i want to use it as an editable that means when user will type something in combobox, according to that text only matching item
HashMap and HashCode
.style1 {
color: #FFFFFF;
}
HashMap and HashCode
The HashMap... how to use HashCode :
package simpleCoreJava;
import java.util.Map;
import... {
public static void main(String args[]) {
Map mp1 = new HashMap();
mp1.put(1
Jstl c:when,c:choose,c:otherwise tag in jsp
JSTL c:when,c:choose,c:otherwise TAGS IN JSP
In this Section, we will discuss about how to use JSTL tag ' c:when ' in JSP
with a simple example.
Basically, the choose, when, and otherwise tags are used to construct an "c
how to use JOptionPane.YES_NO_OPTION
how to use JOptionPane.YES_NO_OPTION As i said earliar i am making HRMS , the last phase is logout button.
when logout button is clicked , an option... to use JOptionPane.YESNOOPTION so that i can give user choice of yes or no before
Use Ordered List In JSP Use Ordered List In JSP I created a Sting that contains ... . This string is generated dynamically from the db. When I place the string in the jsp, it does not create the ordered list. I can paste that string in the jsp
How to use bytes
How to use bytes I have saved my project and uploaded the picture. But when i want to view the picture, there was no picture. I used the method listEmployeeByID and the bean is
if (rs.next()) {
bean.setEmployeephoto
Random numbers - Introduction
Java NotesRandom numbers - Introduction
When to use random numbers
There are many types of programs that use random numbers.
Game programs use them... situation,
or a deck of cards must be shuffled.
Simulations usually use random
Java Hashmap Iterator
Java HashMap Iterator is a collection class. It implements the Map interface.
It keeps the data in the key and value form.
Java HashMap has no iterator method.
So use the entrySet() method.It returns the data in Set object
form
loag already in use atomikos
loag already in use atomikos I am facing an issue only on live... on the server is
Error in init(): Log already in use?
complete exception stack trace
java.lang.RuntimeException: Log already in use
How to use Map in velocity
;ArrayList();
Map map = new HashMap();
 ...
How to use Map in velocity
This
Example shows you how
to use map in velocity. The method
How to use List in velocity
How to use List in velocity
This
Example shows you how
to use List in velocity. ...; ArrayList list = new ArrayList();
Map 
How can store image in server folder when deployed with a .war file?
How can store image in server folder when deployed with a .war file? Hi all;
When I am using application.getRealPath() , it return null when deployed with a .war file and when I use hard code it shows syntax error or path
hashmap with struts and jsp - Struts hashmap with struts and jsp i am trying to use hash map in struts.I am inserting on class object as value and string as key.This object is of class type like UserMaster{username,userId.....}.My problem is that its working fine
How to change table row color when click on Hyper Link in jsp?
How to change table row color when click on Hyper Link in jsp? I use...
row2
row3..
when click on the link1 automatically change the the row1 color,similarly when click on the link2 automatically change the the row2
Collection : HashMap Example HashMap as -
HashMap map=new HashMap();
In HashMap for adding new element we use...Collection : HashMap Example
This tutorial will help you in understanding of HashMap concept.
HashMap :
The java.util.HashMap class implements Map
Windows Mobile Development is Easy to Use When the Right Tools Work
Windows Mobile Development is Easy to UseWhen the Right Tools Work
It can... any bugs in it. It will help to use this before trying to test any application.... The ActiveSync program can also be used if a person wishes to use that instead
Use Map to display file data into textfields Use Map to display file data into textfields
Collection framework allows.... You have mostly
used ArrayList or Vector classes to store the file data. In this section, you will learn how to store the file data into HashMap in the form
How to use Arraylist object in <s:dobleselect> .... struts 2? - Struts
How to useArraylist object in .... struts 2? Hi Members,
I saw the example of tag in roseindia, its very useful. But I have to use my ArrayList object with that tag.
Im retrieving the values for arraylist object from
How to use this keyword in java
How to use "this" keyword in java
The keyword this is useful when you need
to refer... use this keyword. Here, this section provides you an example
with the complete
What is use of method overloading and overriding?
What is use of method overloading and overriding? Method overriding... write same method with different signatures.But I want to know what is the use of these concepts.how to use this type of polymorphism in real time?
thanks
Use of <x:choose> tag of JSTL Use of <x:choose> tag of JSTL
In this section we will learn how to use <x...;
<x:when select="$emp
How to use Token Interceptor - Struts
How to use Token Interceptor Hi,
Iam a beginner in struts.
I tried to implement Token Interceptor to prevent double submission,
I search...
in action tag of struts.xml
When i click the button first time itself it shows
why we use abstract class in java?
why we use abstract class in java? what is the the purpose of abstract class.Give example when to use abstract and whenuse interface