This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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
posted
0
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
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
posted
0
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!!
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.
Never ascribe to malice that which can be adequately explained by stupidity.
Shashank Mittal
Greenhorn
Joined: Nov 30, 2009
Posts: 9
posted
0
well said FRED!
Thanks for that great TIP. I will take care of it next time. Really!
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.