java


Equals two Variables from two Arraylists


I want to create simple cash register.
I already have two ArrayLists, one is my "DataBase" second is used to store purchased products. How can I equal ID from DataBase with ID from input product? In the ArrayLists I have variable id, name and price.
Arraylists<Products> products = new ArrayLists<Products>(); <- Database
ArrayLists<purchased> purchased = new ArrayLists<purchased>() <-List of purchased products
I passed to the function object Product.
For such case it is better to use Maps rather than Lists. IDs will be keys and objects will be values.
With Lists you have to loop through them and compare ID,, each time you need to find a match. But with Maps you just use dbmap.get(ID) or productMap.get(ID) and you have your object instantly.

Related Links

Soap request with namespace
NamingException: jta.UserTransaction
BadParcelable Exception occasionally causing app to crash
Error when reading Excel in R: java.lang.OutOfMemoryError: Java heap space [duplicate]
Loading Hive table from Windows machine (Load data local inpath)
Java no abstract and does not override error
How to prevent Gradle from including the resource files in the JAR
ProgressMonitorDialog and user interaction
Java upload file to server php
Apache Camel - Spring Web App - Camel Context not started on #PostConstruct
How to validate Integer received from a socket stream in java
Java Hashtable set all keys with same value
Apache Mina UDP Client: java.net.PortUnreachableException
(Process String) in Java program
Failed to instantiate com.google.android.gms.common.SignInButton
KeyListener added as own class is not working [duplicate]

Categories

HOME
multithreading
image
cloud
hook
gremlin
server
plone
spagobi
amortized-analysis
rubygems
v8
flyway4
datastax-java-driver
communication
nano-server
kentor-authservices
serverless-framework
clearcase-ucm
jsdoc
reactcsstransitiongroup
connection-string
oxyplot
sylius
excel-2007
lcd
microsoft-sync-framework
status
chromebook
user-interaction
linkerd
fluentvalidation
buck
primitive
gsmcomm
bcd
jspresso
disassembling
bitbucket-pipelines
vapor
az-application-insights
jna
ws-security
email-templates
google-closure
http-live-streaming
nxlog
import-from-excel
reactive-cocoa-5
sencha-touch-2.3
auto-update
rainbowtable
azure-application-gateway
apache-fop
revapi
clean-architecture
qtwebview
flutterwave
ableton-live
vmware-tools
gridview-sorting
qcustomplot
make-install
whois
pickadate
historian
maven-tomcat-plugin
python-3.2
ruby-2.2
android-listview
sysinternals
apache-commons-fileupload
createprocessasuser
system32
unity5.2.3
javax.mail
clicktag
dd
codeigniter-url
asp.net-dynamic-data
issuu
rdl
terminfo
google-reader
openexr
uitouch
jquery-layout
undefined-reference
oracle-warehouse-builder
meteor-velocity
algebraic-data-types
industrial
terminal-services
shellexecute
gwt-rpc
html4
jquery-mobile-dialog
random-seed
interface-orientation
ember-app-kit
robotics-studio
factory-method
viewswitcher
semantic-diff
hgsubversion
gnustep
cinema-4d
file-comparison
asp.net-mvc-areas
database-management
uiq3

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App