Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what wrong with my code?

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Java reserved words

thanks buddy
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Olivier López
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

=)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic