Results 1 to 20 of 28
- 06-01-2009, 12:47 PM #1
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
E:\IT 215 Java Programming\Inventory.java:178: cannot find symbol
This is my share in part five of six programs for class 215. You can beleive that I am tired because you are tired. So lets get on with it.
[errors]Java Code:import java.util.*; import javax.swing.*; import java.awt.event.*; import java.text.*; public class Inventory { // This constant is the max # of inventory items: public static final int maxItems = 10000; // main() method begins execution of a Java application: public static void main( String args[] ) { // This flag will control whether we exit the loop below: boolean stop = false; // This array will hold the entire inventory: ProductWithLength inventory[] = new ProductWithLength[maxItems]; // This counter will count the number of items in the inventory: int numItems = 0; // Loop until user indicates to exit the app: while (!stop) { // Show title, and read product number and store in memory: String itemNumber = JOptionPane.showInputDialog("Office Supply Inventory Program.\n\n " + "Please enter a new product number or press Cancel to end this program: " ); // Check for user clicking Cancel: if (itemNumber == null) { // User clicked Cancel, set flag so we'll exit: stop = true; } else { // User did not click Cancel, so continue reading info for this iteration... float unitAmount = -1; // Number of units String unitAmountStr = ""; // String representation of # of units float price = -1; // Price of unit String priceStr = ""; // String representation of price float value; // Value of units multiplied by price int length = -1; // Length of product String lengthStr = ""; // String representation of length // Prompt for and read product name: String productName = JOptionPane.showInputDialog("Please enter the product name:\n\n"); // Prompt for and read number of units, until a positive // value is entered: while (unitAmount <= 0) { unitAmountStr = JOptionPane.showInputDialog( "Please enter the number of units (value must be greater than 0):\n\n"); try { unitAmount = Float.parseFloat(unitAmountStr); } catch(Exception ex) { } } // Prompt for and read price per unit, until a positive // value is entered: while (price <= 0) { priceStr = JOptionPane.showInputDialog( "Please enter the price per unit (value must be greater than 0):\n\n"); try { price = Float.parseFloat(priceStr); } catch(Exception ex) { } } // Prompt for and read length, until a positive // value is entered: while (length <= 0) { lengthStr = JOptionPane.showInputDialog( "Please enter the length per unit (value must be greater than 0):\n\n"); try { length = Integer.parseInt(lengthStr); } catch(Exception ex) { } } // Now we know units, price and length are positive values. // Instantiate a ProductWithLength to hold this inventory item: ProductWithLength p1 = new ProductWithLength(itemNumber, productName, unitAmount, price, length); // Add this Product to the inventory array: inventory[numItems] = p1; // Increment item counter: numItems++; } } // User has indicated to exit application... // Check for empty inventory: if (numItems == 0) { // No products in inventory... JOptionPane.showMessageDialog(null, "No products were entered into the inventory.\n" + "Unable to display output.", "No Products Entered", JOptionPane.ERROR_MESSAGE); } else { // There are some products in inventory... // Trim the inventory array of all but actual Product objects: inventory = trimInventoryArray(inventory, numItems); // Sort the inventory array by product name: sortInventoryByName(inventory); // Display output for entire inventory... JOptionPane.showMessageDialog(null, "Thank you for your input.\n" + "Please press OK for inventory display.", "Stop Request Received", JOptionPane.INFORMATION_MESSAGE); // Loop through inventory items and display info about each: for (int i=0; i < numItems; i++) { JOptionPane.showMessageDialog( null, // Product info: "Product Number: " + inventory[i].getitemNumber() + "\n" + // product # "Product Name: " + inventory[i].getproductName() + "\n" + // product name "Units in stock: " + inventory[i].getunitAmount() + "\n" + // # units "Length: " + inventory[i].getLength() + "\n" + // length String.format("Price of each unit: $%,.2f\n", inventory[i].getunitPrice()) + // unit price String.format("Restocking fee: $%,.2f\n", inventory[i].getRestockingFee()) + // restocking fee String.format("Inventory value is $%,.2f\n", inventory[i].calculateValue()), // inventory value "Item #" + (i+1) + " of " + numItems, // this is the window title JOptionPane.INFORMATION_MESSAGE); } // Display total inventory value: JOptionPane.showMessageDialog(null, String.format("Value of entire inventory is $%,.2f\n", Inventory.calcEntireValue(inventory, numItems)), "Total Inventory Value", JOptionPane.INFORMATION_MESSAGE); } // Display ending message: JOptionPane.showMessageDialog(null, "Thank you for using the Office Supply Inventory Program!", "Adios!", JOptionPane.PLAIN_MESSAGE); } // end method main // Trim inventory array to specified size: public static ProductWithLength[] trimInventoryArray(ProductWithLength[] inventory, int numItems) { ProductWithLength[] returnVal = new ProductWithLength[numItems]; for (int i=0; i < numItems; i++) { returnVal[i] = inventory[i]; } return returnVal; } // Calculate the value of the entire inventory. public static float calcEntireValue(Product[] inven, int numItems) { float value = 0; // Loop through products and add their values to the total: for (int i=0; i < numItems; i++) { value += inven[i].calculateValue(); } return value; } // Sort the inventory array by product name: public static void sortInventoryByName(Product[] inven) { Arrays.sort(inven); } } // end class Inventory
E:\IT 215 Java Programming\Inventory.java:178: cannot find symbol
symbol : class ProductWithLength
location: class Inventory
public static ProductWithLength[] trimInventoryArray(ProductWithLength[] inventory, int numItems)
^
E:\IT 215 Java Programming\Inventory.java:178: cannot find symbol
symbol : class ProductWithLength
location: class Inventory
public static ProductWithLength[] trimInventoryArray(ProductWithLength[] inventory, int numItems)
^
E:\IT 215 Java Programming\Inventory.java:191: cannot find symbol
symbol : class Product
location: class Inventory
public static float calcEntireValue(Product[] inven, int numItems)
^
E:\IT 215 Java Programming\Inventory.java:205: cannot find symbol
symbol : class Product
location: class Inventory
public static void sortInventoryByName(Product[] inven)
^
E:\IT 215 Java Programming\Inventory.java:18: cannot find symbol
symbol : class ProductWithLength
location: class Inventory
ProductWithLength inventory[] = new ProductWithLength[maxItems];
^
E:\IT 215 Java Programming\Inventory.java:18: cannot find symbol
symbol : class ProductWithLength
location: class Inventory
ProductWithLength inventory[] = new ProductWithLength[maxItems];
^
E:\IT 215 Java Programming\Inventory.java:105: cannot find symbol
symbol : class ProductWithLength
location: class Inventory
ProductWithLength p1 =
^
E:\IT 215 Java Programming\Inventory.java:106: cannot find symbol
symbol : class ProductWithLength
location: class Inventory
new ProductWithLength(itemNumber, productName, unitAmount, price, length);
^
E:\IT 215 Java Programming\Inventory.java:180: cannot find symbol
symbol : class ProductWithLength
location: class Inventory
ProductWithLength[] returnVal = new ProductWithLength[numItems];
^
E:\IT 215 Java Programming\Inventory.java:180: cannot find symbol
symbol : class ProductWithLength
location: class Inventory
ProductWithLength[] returnVal = new ProductWithLength[numItems];
^
E:\IT 215 Java Programming\Inventory.java:198: inconvertible types
found : <nulltype>
required: float
value += inven[i].calculateValue();
^
11 errors
Tool completed with exit code 1
[/errors]
- 06-01-2009, 02:43 PM #2
Member
- Join Date
- Apr 2009
- Posts
- 54
- Rep Power
- 0
I suggest you make a more simple case showing your problem ... sometimes that may also give you the solution of your problem. To find line 178 witout linenumbers is hard work.
-
Life is not the worst thing we have ... in a few minutes my coffee is ready.
- 06-01-2009, 03:43 PM #3
Surely by now you should have worked out what "cannot find symbol" means?
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 06-02-2009, 02:06 PM #4
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
made some changes to 11 errors now I have four errors
[errors]Java Code:import java.util.*; import javax.swing.*; import java.awt.event.*; import java.text.*; import javax.swing.JOptionPane; public class Inventory // line (7) { // This constant is the max # of inventory items: public static final int maxItems = 10000; // main() method begins execution of a Java application: public static void main( String args[] ) { // This flag will control whether we exit the loop below: boolean stop = false;// line 16 // This array will hold the entire inventory: ProductWithLength inventory[] = new ProductWithLength[maxItems]; // This counter will count the number of items in the inventory: int numItems = 0; // Loop until user indicates to exit the app: while (!stop) { // Show title, and read product number and store in memory: String itemNumber = JOptionPane.showInputDialog("Office Supply Inventory Program.\n\n " + "Please enter a new product number or press Cancel to end this program: " ); // line 31 // Check for user clicking Cancel: if (itemNumber == null) { // User clicked Cancel, set flag so we'll exit: stop = true; } else { // User did not click Cancel, so continue reading info for this iteration... float unitAmount = -1; // Number of units String unitAmountStr = ""; // String representation of # of units float price = -1; // Price of unit String priceStr = ""; // String representation of price float value; // Value of units multiplied by price int length = -1; // Length of product String lengthStr = ""; // String representation of length //line 49 // Prompt for and read product name: String productName = JOptionPane.showInputDialog("Please enter the product name:\n\n"); // Prompt for and read number of units, until a positive // value is entered: while (unitAmount <= 0) { unitAmountStr = JOptionPane.showInputDialog( "Please enter the number of units (value must be greater than 0):\n\n"); try {// line 63 unitAmount = Float.parseFloat(unitAmountStr); } catch(Exception ex) { } } // Prompt for and read price per unit, until a positive // value is entered: while (price <= 0) { priceStr = JOptionPane.showInputDialog( "Please enter the price per unit (value must be greater than 0):\n\n"); try { price = Float.parseFloat(priceStr); } catch(Exception ex) { } }// line 85 // Prompt for and read length, until a positive // value is entered: while (length <= 0) { lengthStr = JOptionPane.showInputDialog( "Please enter the length per unit (value must be greater than 0):\n\n"); try { length = Integer.parseInt(lengthStr); } catch(Exception ex) { }// line 100 } // Now we know units, price and length are positive values. // Instantiate a ProductWithLength to hold this inventory item: ProductWithLength p1 = new ProductWithLength(itemNumber, productName, unitAmount, price, length); // Add this Product to the inventory array: inventory[numItems] = p1; // Increment item counter: numItems++; } }// line 115 // User has indicated to exit application... // Check for empty inventory: if (numItems == 0) { // No products in inventory... JOptionPane.showMessageDialog(null, "No products were entered into the inventory.\n" + "Unable to display output.", "No Products Entered", JOptionPane.ERROR_MESSAGE); } else {// line 130 // There are some products in inventory... // Trim the inventory array of all but actual Product objects: inventory = trimInventoryArray(inventory, numItems); // Sort the inventory array by product name: sortInventoryByName(inventory); // Display output for entire inventory... JOptionPane.showMessageDialog(null, "Thank you for your input.\n" + "Please press OK for inventory display.", "Stop Request Received", JOptionPane.INFORMATION_MESSAGE); // line 145 // Loop through inventory items and display info about each: for (int i=0; i < numItems; i++) { JOptionPane.showMessageDialog( null, // Product info: "Product Number: " + inventory[i].getitemNumber() + "\n" + // product # "Product Name: " + inventory[i].getproductName() + "\n" + // product name "Units in stock: " + inventory[i].getunitAmount() + "\n" + // # units "Length: " + inventory[i].getLength() + "\n" + // length String.format("Price of each unit: $%,.2f\n", inventory[i].getunitPrice()) + // unit price String.format("Restocking fee: $%,.2f\n", inventory[i].getRestockingFee()) + // restocking fee String.format("Inventory value is $%,.2f\n", inventory[i].calculateValue()), // inventory value "Item #" + (i+1) + " of " + numItems, // this is the window title JOptionPane.INFORMATION_MESSAGE); } // Display total inventory value: JOptionPane.showMessageDialog(null, String.format("Value of entire inventory is $%,.2f\n", Inventory.calcEntireValue(inventory, numItems)), "Total Inventory Value", JOptionPane.INFORMATION_MESSAGE); } // Display ending message: JOptionPane.showMessageDialog(null, "Thank you for using the Office Supply Inventory Program!", "Adios!", JOptionPane.PLAIN_MESSAGE); } // end method main // Trim inventory array to specified size: public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems) {// line 179 ProductWithLength[] length = new ProductWithLength[numItems]; for (int num=1; i < numItems; num++) { returnVal[i] = inventory[i]; } return returnVal; } // Calculate the value of the entire inventory. // line 190 public static float calcEntireValue(Product[] inven, int numItems) { float value = 0; // Loop through products and add their values to the total: for (int i=0; i < numItems; i++) { value += inven[i].calculateValue(); } // line 200 return value; } // Sort the inventory array by product name: public static void sortInventoryByName(Product[] inven) { Arrays.sort(inven); } } // end class Inventory // line 210
E:\IT 215 Java Programming\Inventory.java:179: <identifier> expected
public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
^
E:\IT 215 Java Programming\Inventory.java:179: '.class' expected
public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
^
E:\IT 215 Java Programming\Inventory.java:179: <identifier> expected
public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
^
E:\IT 215 Java Programming\Inventory.java:179: <identifier> expected
public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
^
4 errors
Tool completed with exit code 1
Try it again. Thank you. Almost done until next Java class working for my bachelors degree. Thank you again.
- 06-02-2009, 03:20 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
- 06-02-2009, 05:45 PM #6
What is it?
Yes, look at that line, very carefully...Java Code:public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems)
- It has a closing parentesis ... where is the opening parentesis?
- Is the line the begining of a method? If so, what are the arguments being passed to the method and was is the type that it is returning?
- If it's something else, please explain.
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 06-02-2009, 06:07 PM #7
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
Code and errors
I know this is where my problem lies. The first line is asking for a 'class'. So implement class inbetween public and static and I get the same ole errors. Nothing changes. Besides that I rewritten the code as "public static ProductWithLength[]; Inventory.ProductWithLength; number; and I am still told that it is wrong somewhere adn I have worked on the for loop because you should have seen it before it was all out of wake but I have a feeling once I clear up the line one problem the line three problem will show up again. Any suggestions? It is supposed to be a method. I think the parenthesis was type o. At the time of writing it it sounded normal but it looks at little trumped up now. Still working on it. I have looked and compared the method and for loop to others that I have accomplished and in variance the differ mildly, because they are different programs.Java Code:public static ProductWithLength[], Inventory=ProductWithLength[] , int numItems) // line 1 {// line 179 ProductWithLength[] = new ProductWithLength[number]; // line two of one for (int number=1; number<10000; number++) // line three of one
- 06-02-2009, 06:11 PM #8
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
Hello, How are you today?
I just noticed that certain members or moderators are from different parts of the world. That is awesome. I heard that there was an earthquake in Honduras but your in Mexico. How's the weather?
- 06-02-2009, 06:21 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
No no no no no no no.
Ignore the specifics of the error message in this case...it's the compiler going "I haven't got a clue what you're trying to do here, but here's my set of best guesses". More often than not, with a line as wrong as this one, simply trying to follow what the compiler says will simply get you more errors, and code that is more wrong than a wrong thing.
If you can't see what's wrong with that line, without looking at the compiler, then you really need to go back to basics on Java syntax. What a class looks like, what it contains, how you declare it...and in this case (I suspect) what a method should look like.
Since you're new to all this, you should have one class per file. Don't even think about going down the road of inner classes or any of that stuff. Consequently should you get errors like this you'll know there's something very wrong with your code, and won't flail around trying to add classes where they're not needed.
So, a class looks like:
An attribute declaration looks like:Java Code:public class MyClass { // list of attributes // my methods }
A method looks like:Java Code:private String myAttribute;
Java Code:public String doSomething(int someParameter, String anotherParameter) { // Some code that does stuff }
- 06-02-2009, 06:54 PM #10
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
Tolls method
[errors]Java Code:// Trim inventory array to specified size: public static void main (String[] args) {(Product[] Inventory.Product[] = int number)} {// line 179 Product[] = new Inventory.Product[int];} for (int number=1; number<10000; number++) { returnVal[int] = inventory[int]; }
E:\IT 215 Java Programming\Inventory.java:180: ')' expected
{(Product[] Inventory.Product[] = int number)}
^
E:\IT 215 Java Programming\Inventory.java:180: '.class' expected
{(Product[] Inventory.Product[] = int number)}
^
E:\IT 215 Java Programming\Inventory.java:180: '.class' expected
{(Product[] Inventory.Product[] = int number)}
^
E:\IT 215 Java Programming\Inventory.java:180: illegal start of expression
{(Product[] Inventory.Product[] = int number)}
^
E:\IT 215 Java Programming\Inventory.java:180: ';' expected
{(Product[] Inventory.Product[] = int number)}
^
E:\IT 215 Java Programming\Inventory.java:183: not a statement
Product[] = new Inventory.Product[int];}
^
E:\IT 215 Java Programming\Inventory.java:183: ';' expected
Product[] = new Inventory.Product[int];}
^
E:\IT 215 Java Programming\Inventory.java:183: '.class' expected
Product[] = new Inventory.Product[int];}
^
E:\IT 215 Java Programming\Inventory.java:183: not a statement
Product[] = new Inventory.Product[int];}
^
E:\IT 215 Java Programming\Inventory.java:187: '.class' expected
returnVal[int] = inventory[int];
^
E:\IT 215 Java Programming\Inventory.java:187: '.class' expected
returnVal[int] = inventory[int];
^
11 errors
Tool completed with exit code 1
[errors]:confused:
- 06-02-2009, 07:05 PM #11
STOP PROGRAMMING
Seriously, do not touch a text editor or IDE until you've gone away and learnt the basics of Java syntax. The mind boggles at how you've managed to get all the way to part 5.Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 06-02-2009, 07:45 PM #12
Study methods...
tlouvierre... please don't take this the wrong way, but I think your trying to bite too much off without understanding the basics. Comments like:
andI rewritten the code as "public static ProductWithLength[]; Inventory.ProductWithLength; number;
... indicate to me that you don't know what your doing. The above doesn't come close to being a method and confuses the hell out of the compiler.It is supposed to be a method.
I suggest you look at the following to understand what a method should looks like and how it works:
Defining Methods (The Java Tutorials > Learning the Java Language > Classes and Objects)
Passing Information to a Method or a Constructor (The Java Tutorials > Learning the Java Language > Classes and Objects)
Returning a Value from a Method (The Java Tutorials > Learning the Java Language > Classes and Objects)
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 06-03-2009, 09:06 AM #13
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
That looks nothing like the templates I put up there, does it...
Go with the links CJSLMAN has posted and learn the basics, honestly.
ETA: Out of curiosity, what languages (if any) have you coded in before, including scripting ones. It might give us a clue as to why you're coding like this.
- 06-03-2009, 03:28 PM #14
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
- 06-03-2009, 03:33 PM #15
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
There is nothing wrong with my coding and no I am not on drugs. The refurbished items that I have attempted work just fine in other programs. Why don't they work on this one? Same thing I rewrote the for loop and looks decent. Not enough sleep is my drug of choice. So I made a mistake and need to fix it and I must know what I am talking about if I can get four programs to compile and you can get even one. So much for getting help from Java Forums. I try and initiate conversation and all I get are insults. Thanks but no thanks give me back Singboyo at least he leads me in the right direction!
- 06-03-2009, 03:47 PM #16
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
Java Code:// Trim inventory array to specified size: public double ProductWithLength (double ProductWith Length, int Inventory, double length, double inventory) {// line 179 Product[] = new Inventory.Product[int];} for (int number=1; number<10000; number++) { returnVal[int] = inventory[int]; } return returnVal;
- 06-03-2009, 03:50 PM #17
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
- 06-03-2009, 04:06 PM #18
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
[errors]Java Code:// Calculate the value of the entire inventory. // line 190 public static class ProductWithLength // definition of class {// line 179 ProductWithLength[] length = new ProductWithLength[numItems];} for (int i=1; i<10000; i++) { returnVal[i] = inventory[i]; } return returnVal; }
E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
for (int i=1; i<10000; i++)
^
E:\IT 215 Java Programming\Inventory.java:186: ')' expected
for (int i=1; i<10000; i++)
^
E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
for (int i=1; i<10000; i++)
^
E:\IT 215 Java Programming\Inventory.java:186: <identifier> expected
for (int i=1; i<10000; i++)
^
E:\IT 215 Java Programming\Inventory.java:186: ';' expected
for (int i=1; i<10000; i++)
^
E:\IT 215 Java Programming\Inventory.java:186: <identifier> expected
for (int i=1; i<10000; i++)
^
E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
for (int i=1; i<10000; i++)
^
E:\IT 215 Java Programming\Inventory.java:186: '(' expected
for (int i=1; i<10000; i++)
^
E:\IT 215 Java Programming\Inventory.java:191: illegal start of type
return returnVal;
^
E:\IT 215 Java Programming\Inventory.java:191: ';' expected
return returnVal;
^
E:\IT 215 Java Programming\Inventory.java:193: class, interface, or enum expected
public static float calcEntireValue(Product[] inven, int numItems)
^
E:\IT 215 Java Programming\Inventory.java:198: class, interface, or enum expected
for (int i=0; i < numItems; i++)
^
E:\IT 215 Java Programming\Inventory.java:198: class, interface, or enum expected
for (int i=0; i < numItems; i++)
^
E:\IT 215 Java Programming\Inventory.java:198: class, interface, or enum expected
for (int i=0; i < numItems; i++)
^
E:\IT 215 Java Programming\Inventory.java:201: class, interface, or enum expected
}
^
E:\IT 215 Java Programming\Inventory.java:204: class, interface, or enum expected
}
^
E:\IT 215 Java Programming\Inventory.java:207: class, interface, or enum expected
public static void sortInventoryByName(Product[] inven)
^
E:\IT 215 Java Programming\Inventory.java:210: class, interface, or enum expected
}
^
18 errors
Tool completed with exit code 1
[errors]
Turns out it was a class because the following line did not pose any errors. I did read the literature that you gave me but none of it made since. Not for what the program holts and no I don't drink. Not even Nyquil. I have been walking around in this fog for a couple of days and can't seem to shake it. I you have no respect for me. So enough for both of us. Hah.
- 06-03-2009, 04:29 PM #19
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
I doubt it's a class.
Your class, as posted in the original post, is Inventory. Presumably sitting in a file Inventory.java.
Re-read my earlier post where I showed you what the (basic) structure of a Class (and its components) is.
Go through you Inventory class and restructure it so it matches that structure. Stop trying to fix the compiler errors that you're seeing, since they are the sort of massed errors you get when there is something fundamentally wrong with what's in your code.
- 06-03-2009, 09:25 PM #20
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
logistics
I am not asking why it is an error. I mean I know it is an error but in my head it is logical but in reality it is an error. I solved the error but am left with more errors to a basic for loop... I have tried every thing to get this for loop to be kosher but it just won't gel. Take a look.
[code]
public static class ProductWithLength // definition of class
{// line 179
ProductWithLength[] length = new ProductWithLength[numItems];}
for (int i=0; i<10000; i++)// line 186
{
returnVal[i] = inventory[i];
}
[code]
[errors]
E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
for (int i=0; i<10000; i++)// line 186
^
E:\IT 215 Java Programming\Inventory.java:186: ')' expected
for (int i=0; i<10000; i++)// line 186
^
E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
for (int i=0; i<10000; i++)// line 186
^
E:\IT 215 Java Programming\Inventory.java:186: <identifier> expected
for (int i=0; i<10000; i++)// line 186
^
E:\IT 215 Java Programming\Inventory.java:186: ';' expected
for (int i=0; i<10000; i++)// line 186
^
E:\IT 215 Java Programming\Inventory.java:186: <identifier> expected
for (int i=0; i<10000; i++)// line 186
^
E:\IT 215 Java Programming\Inventory.java:186: illegal start of type
for (int i=0; i<10000; i++)// line 186
^
E:\IT 215 Java Programming\Inventory.java:186: '(' expected
for (int i=0; i<10000; i++)// line 186
^
I have tried (int num=1; ProductWithLength<10000; numItems++), I have tried (int i=0, i<length; i++). I have just switching around the numbers and lengths and I get no where. I mean I wrote in a basic for loop as a reference to go back and solve the issue but I am not invisioning that now. Can you help out? At least lead me in the right direction.
Similar Threads
-
E:\IT 215 Java Programming\InventoryGUI.java:20: cannot find symbol
By tlouvierre in forum Advanced JavaReplies: 21Last Post: 06-01-2009, 12:52 PM -
E:\IT 215 Java Programming\Inventory.java:211: reached end of file while parsing
By tlouvierre in forum New To JavaReplies: 1Last Post: 05-31-2009, 06:48 PM -
E:\IT 215 Java Programming\Inventory.java:36: class, interface, or enum expected
By tlouvierre in forum Advanced JavaReplies: 16Last Post: 05-28-2009, 03:41 PM -
java:34:cannot find symbol
By MissyMadi in forum New To JavaReplies: 5Last Post: 11-09-2008, 06:53 PM -
[SOLVED] Java Error: Cannot find Symbol...
By bobleny in forum New To JavaReplies: 8Last Post: 04-15-2008, 06:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks