wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Java Problem = List of errors, Clueless. HELP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Problem = List of errors, Clueless. HELP" Watch "Java Problem = List of errors, Clueless. HELP" New topic
Author

Java Problem = List of errors, Clueless. HELP

Shashank Mittal
Greenhorn

Joined: Nov 30, 2009
Posts: 9
Thats my code guys.



And attached is the error thrown at compile time.


Please help me Guys!! I am frustrated as well belittled by my own class fellows


[Thumbnail for Untitled.jpg]



Lord don't move that mountain, Give me the strength to climb it.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

The method main is missing an opening bracket {.
B.t.w. you could simplify your code by using the ++ operator.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Shashank Mittal
Greenhorn

Joined: Nov 30, 2009
Posts: 9
OUCH!!!
Thank you!
But I seem to have this frequent problem.
whenever I call anyother variable in Soprintln, it says can;t reference from non static context.
I have to declare the variable as static, is there anyway to override this problem.
Thanks again
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

A common problem for beginners. Because the main method is static you can't use non-static variables. You must created an instance and perform actions on that instance. However I would advise you to read some things about what static actually means. Because it is very basic and you must understand it in order to become a good programmer. It is not that difficult. Good luck
Shashank Mittal
Greenhorn

Joined: Nov 30, 2009
Posts: 9
Thanks Wouter

Any good books you can refer, by good books, I really mean good books for a silly person like me! :P
Thanks again main...errr....man!!
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

as a general note, you should never have gotten this error. Why? because you shouldn't have written this much code before compiling. Every time I write a program, I write exactly this before I compile it the first time



Once I compile this, I run it and make sure it does what I think it should, I write another line. and by that, I mean ONE line. Ok, I may declare a variable AND write a line, but not much more than that.

the idea is to write as little as possible before each compile/run/debug cycle. by doing this, you can be pretty sure where the error is. I use liberal System.out.println statements when writing my code too. I like to know exactly what it is doing at each and every step.

Writing 32 lines of code before compiling it scare the heck out of me...I would STRONGLY advise you not to do it. If you had done this, you would have pretty quickly found your missing brace, rather than getting this massive list of errors which are all caused by one missing character.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Shashank Mittal
Greenhorn

Joined: Nov 30, 2009
Posts: 9
well said FRED!
Thanks for that great TIP. I will take care of it next time. Really!
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

I can't help you with finding a good book because I learned it almost entirely from the internet. I'd advise you to read sun's java tutorial. It's not the easiest one out there but it's good.
One thing I can't stress enough. Write code, write code, write code, WRITE CODE! Because only then will you learn. If you only read about it then you will never get it. And remember
you can't learn good programming within a day, week, month. It takes lots and lots of practice.
 
 
subject: Java Problem = List of errors, Clueless. HELP
 
Similar Threads
return statement
code
return - problem
how exactly does this code compile?
How to read this?