*
The moose likes Beginning Java and the fly likes Finished my so-called program with many errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Finished my so-called program with many errors " Watch "Finished my so-called program with many errors " New topic
Author

Finished my so-called program with many errors

Reno Madrigal
Greenhorn

Joined: Sep 24, 2007
Posts: 18
So after a few days and countless hours just today i have finished my little program but have some major flaws, I am not asking for answers but more of a guidance towards where I am suppose to be, I feel i am in the ball park concerning this but cant put 2 and 2 together. I will be up a couple more hours, and then again tommorrow after work but please feel free to lend a hand.

Here goes 78 errors of pure bliss according to Jcreator:



EDIT by mw: Added Code Tags.
[ September 24, 2007: Message edited by: marc weber ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

You should seriously consider compiling as you go. Write a few lines, then compile. If you have errors, fix them when they're small. When it compiles without errors, then write a few more lines and compile again... And so on.

I think that's your best shot at debugging this code. Break it down to just a few lines, and gradually add more lines as you fix the errors. (As you do this, you will find that Java does not have an "endIf." Use braces for this. Also, "call" is not a keyword.)

PS: Please use Code Tags when posting code. Thanks!
[ September 24, 2007: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Vishram Khare
Greenhorn

Joined: Sep 23, 2007
Posts: 11
If you have reproduced your code exactly here on this forum,I can see two mistakes for sure.

1) When you compile and try to run a java program,the execution of the program starts from main method.You have not defined a main method in your program.Of course that will not cause a compile time error.Absence of main method will not cause execution of the program at run time.

2)
You entered--

private StagIO io = new StaugIO();

Apparently you are trying to create a new object of the class type StaugIO but on the left hand side you are defining object belonging to class type StagIO. You can do this only if StagIO is a superclass of StaugIO class.But from your code, it does not seem to be.

See if this helps.

----Girish
Reno Madrigal
Greenhorn

Joined: Sep 24, 2007
Posts: 18
I have lowered my errors from 78 to 41 which to me is an improvement but I am still getting multiple errors that include the folllowing:

while expected
illegal start of expression
';' expected
not a statement
'(' expected
')' expected
not a statement
';' expected
illegal start of type
not a statement
not a statement
'(' expected
')' expected
';' expected
';' expected
'(' expected
')' expected
'(' expected
')' expected
'(' expected
')' expected
'(' expected
')' expected
'(' expected
')' expected
'(' expected
')' expected
'(' expected
')' expected
'(' expected
')' expected
';' expected
';' expected
';' expected
not a statement
';' expected
'else' without 'if'
<identifier> expected
<identifier> expected
class, interface, or enum expected
class, interface, or enum expected


marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Most of those errors are pretty descriptive, telling you exactly what you're missing. I assume that they also provide a line number. So knowing what line is missing what... You just need to take one error at a time. If you can't figure them out, tell us exactly what error is happening at exactly which line in the code.

(Again: Neither "endIf" nor "call" are keywords in Java. These have no meaning and will cause errors.)
[ September 25, 2007: Message edited by: marc weber ]
Reno Madrigal
Greenhorn

Joined: Sep 24, 2007
Posts: 18
I have got it down to 15 errors but I really feel somethings I did werent right but it still let it pass when i compiled it. I dont understand the while part also the illegal starts and on line 56 i know I am completely lost because I cant even figure out where to place the ( ) at


while expected LINE 41
illegal start of expression LINE 42
not a statement LINE 52
'(' expected LINE 56
')' expected LINE 56
not a statement LINE 56
';' expected LINE 56
illegal start of type LINE 56
not a statement LINE 56
illegal start of expression LINE 65
'else' without 'if' LINE 168
<identifier> expected LINE 169
<identifier> expected LINE 170
class, interface, or enum expected LINE 181
class, interface, or enum expected LINE 196

I dont mean to be a bore but here is my program again with the only 15 errors:


[ September 25, 2007: Message edited by: Reno Madrigal ]
Reno Madrigal
Greenhorn

Joined: Sep 24, 2007
Posts: 18
any advice?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41180
    
  45
As Marc said, it's much easier for you to figure out what's going wrong, since you have the line numbers.

One thing I noticed is that you seem to assume that in a switch statement, execution of a case ends at the next case statement. That's not the case; if you want execution to stop at the next case statement, you need to insert a "break;" before it.


Ping & DNS - my free Android networking tools app
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Not trying to be rude, but it's good that you learn the Java syntax first before your start coding. Here's a pretty good link:
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/index.html

Anyway, good luck


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41180
    
  45
There's no "endIf" in Java.

This is wrong for two reasons:

The while condition must be inside of the parentheses, and equality is tested using "==", not "=".
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11172
    
  16

you have a "do" that is not followed by braces {}. that means that only one line belongs in the do-body. java is expecting a while after that one line. you probably need braces around a big chunk of code between your 'do' line and your 'while' line (which Ulf points out also needs correcting).


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Finished my so-called program with many errors
 
Similar Threads
Declaring Multiple Private Variables
class/interface/enum errors
Exception in Thread-Inventory Program
Java Collections- Retrival from nested while loops
Assignment does not make sense to me.