wood burning stoves 2.0*
The moose likes Java in General and the fly likes what wrong with my code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "what wrong with my code?" Watch "what wrong with my code?" New topic
Author

what wrong with my code?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

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: 61437
    
  67

Java reserved words


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

Bear Bibeault wrote:Java reserved words

thanks buddy
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

Bear Bibeault wrote:Java reserved words

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: 61437
    
  67

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: 19723
    
  20

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 - OCEEJBD 6
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

=)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what wrong with my code?