Results 21 to 28 of 28
- 06-03-2009, 09:27 PM #21
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
-
There is another coding technique that I think you should master, and I'm not sure what it's called, perhaps coding by progressive iteration, but it goes something like this:
1) Create a class skeleton such as,
2. Make sure that your current code compiles without error. If there's an error, fix it immediately before moving on. ThenJava Code:public MyClass { }
3. Add one line of code.
4. Repeat steps 2. and 3. until program is complete.
The key is to compile and debug frequently and early during your program creation process. If you do this, you will keep errors down to a manageable number. If not, you'll end up with, well what you have now: a hornet's nest of errors. Best of luck.
- 06-03-2009, 11:17 PM #23
There's no need to throw personal insults around. The fact is you've been asking questions here for weeks. Every time we tell you what's wrong you seem to ignore us. Every time we direct you to tutorials or other on-line resources you appear to learn nothing. Every time we fix your code for you, you make exactly the same mistake somewhere else.
Your latest error dump is the same as most of the others - misplaced curly brackets and a complete failure to comprehend classes and methods. Now good day to you.Last edited by OrangeDog; 06-03-2009 at 11:21 PM.
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 06-04-2009, 09:47 AM #24
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
OK, I'll format your code for you, which might point you in the right direction.
Your for loop is not in a method, for starters...it's not even in the ProductWithLength class.Java 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]; }
Your ProductWithLength class makes no sense...static is not a legal modifier for a class.
Is this "class" defined in your Inventory class?
I shall say again, take a step back...restructure your code as I said above...stop thrashing.
You need to think about what you're trying to do here with your (presumably) Inventory class...I haven't a clue. And no, "trying to get the for loop to work" is not an answer to that question.
- 06-05-2009, 01:46 AM #25
Classes about classes
tlouvierre... Like Fubarable & Tolls indicate, you need to study about classes:
What Is a Class? (The Java™ Tutorials > Learning the Java Language > Object-Oriented Programming Concepts)
Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Creating Objects (The Java™ Tutorials > Learning the Java Language > Classes and Objects) (see section about class instantiating)
Generally, (like some else commented) classes are usually not imbedded inside another class (nested classes). It's usually is a separate file and it's methods are called by other classes (if needed) by instantiating the class. For example:
Now on a separate note... please stop being offended when somebody criticizes you (either positive or negative). If you get upset everytime somebody says something you don't like, you will always be upset with the rest of the world. Learn from both the positive and negative comments.Java Code:MyClass mc = new myClass();//instanciating the class int myInt = mc.myMethod();//calling a method of that class
Luck,
CJSLLast edited by CJSLMAN; 06-05-2009 at 01:57 AM. Reason: typo
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 06-05-2009, 10:07 PM #26
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
Quote Quote
Every bit of information that you supplied which is only for methods turned out that I don't need. Because the line is wrote as a class. It is the only thing that fits and fits well. I guess you did not see my update. And I do have a problem with classes with and methods because I don't recognize them. I read the literature but as I said it was for the wrong the class and not the method like I tought it was. You have to admit that it looked like a method being wrote at first and then when applied class the error went away after I had made several other changes too. Can you give information on for loops and classes, please?:)
- 06-06-2009, 12:34 AM #27
Read carefully....
tlouvierre... you must read the posts carefully... above, I already posted 3 links to help you with understanding classes. Here are some for loops:Can you give information on for loops and classes, please?
The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)
The while and do-while Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 06-06-2009, 01:09 AM #28
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
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