hello everyone I am newto programming and I am just a little bit confused. I have three files in java
Product.java this file defines the product attributes like product name, quantity, ID
in this file i dont have a main
ProductCollection.java
this file create a vector to hold data temporarily when accessing database
Database.java
database connection
EServer
communicate with client and retrieve access database
rs = query.executeQuery(queryString);
pColl = new ProductCollection();<-------------------confuse
product extractedProduct; <------------------------ confuse
while(rs.next())
{
extractedProduct = (Product).addProduct(rs);
// Object [ ] extractedProduct = ProductCollection.addProduct(rs);
}
EClient.java
can someone explain this two line please
[ pColl = new ProductCollection();] [ product extractedProduct;]
also I am struggling to add an object to store the result temporary. Can someone help me please I want extract out the contents of a row and set up a Product object extractedProduct
This is as simple assignment. On the left hand side you have a variable,
pColl, and on the right hand side you have an expression that creates a new object of typeProductCollectionand returns a reference to it.This is a variable declaration which says, “from this line on, I want to be able to use a variable which I call
extractedProductand it refers to aproduct” (or, put another way, you declare a variable of typeproduct).The Java convention says that class names should start with a capital letter, so you probably want to change the name of the class so it reads
Useful links: