• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

what wrong with my code?

 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>

 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java reserved words
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

=)
 
Sunglasses. AKA Coolness prosthetic. This tiny ad doesn't need shades:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic