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.
Bad practice or not when running code every 5 seconds?
How can I add two variables in a java subclass to pass as one variable to the superclass?
88byte output from AES encryption
WCF call Java SOAP service - namespace issue
WebSockets in Java EE?
program stalls immediately after beforeclass with log4j and springframework
Java Invalid maximum heap size
Changing EditText style each words contained within
JSoup check if <HTML>,<HEAD> and <BODY> tags are present
How to set a variable equal to null in debug mode within eclipse
Resource IDs and Devices
clear text password issues with Jenkins m2 release plugin or maven release plugin
Cannot save text from Edittext
How to determine which driver to use for JDBC
Want to throw exception when encounter special UTF-8 characters in an XML file
How to remotely build and run applications?