| Author |
what wrong with my code?
|
naved momin
Ranch Hand
Joined: Jul 03, 2011
Posts: 675
|
|
i got an error like this
C:\Users\Admin\Documents\java source code\const>javac const.java
const.java:1: <identifier> expected
class const
^
const.java:5: illegal start of expression
public const()
^
const.java:5: illegal start of expression
public const()
^
const.java:5: ';' expected
public const()
^
const.java:5: illegal start of expression
public const()
^
const.java:5: ';' expected
public const()
^
const.java:18: illegal start of expression
const c = new const();
^
const.java:18: <identifier> expected
const c = new const();
^
const.java:18: '(' or '[' expected
const c = new const();
^
const.java:18: ';' expected
const c = new const();
^
const.java:18: illegal start of expression
const c = new const();
^
11 errors
C:\Users\Admin\Documents\java source code\const>
|
The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56152
|
|
|
Java reserved words
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
naved momin
Ranch Hand
Joined: Jul 03, 2011
Posts: 675
|
|
thanks buddy
|
 |
naved momin
Ranch Hand
Joined: Jul 03, 2011
Posts: 675
|
|
how you guyz recognize error so earlly , can you give me some tips .please
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56152
|
|
|
First, you didn't follow conventions and use an initial capital letter for the class name. Second, having been writing Java for over 10 years, I simply recognized that you were trying to use a reserved word.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Of course, getting our certification helps in recognizing one of the more obscure reserved words. I say obscure because it's reserved yet has no meaning (yet). goto is the other not-used reserved word, and let's hope it stays that way. I wouldn't mind if const would finally get meaning (like an array that cannot be modified, or for immutable objects where the immutability is guaranteed by the compiler), but goto... brrrrrrr.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Olivier López
Ranch Hand
Joined: Jan 31, 2010
Posts: 32
|
|
You want a tip?
If you look, the word "const" is in a special/different color, so it means is a reserved word and
cannot be used as a class/method/constructor/variable name
=)
|
 |
 |
|
|
subject: what wrong with my code?
|
|
|