• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compile time errors

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class X090
{
private static int a;
System.out.println("" +a);
public static void main (String[] args)
{
modify (a);
}
public static void modify (int a)
{
a++;
System.out.println("" +a);
}
}

can anybody correct the compile time errors for the above program

thanks,
venkat
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Venkat, please edit your code and surround it with markers. (I have done it enough times for you). That will maintain the formatting if any. Do it as a courtesy to your readers. Otherwise, some will not even bother to read your code or help you understand your problem.
Thanks
-Barry
[ May 16, 2005: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To solve your own problem, think where you can and cannot put executable statements.
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Venkat,

OK, let's analyze the compiler error message.



According the error message above, the compiler doesn't seem to be happy with line 4. What's next? Comment out that line and recompile the code. And this time, it should go thru' without any problem. As mentioned, we can't place any statement anywhere we like; there're rules to which we must adhere when coding: JLS 2.

Joyce
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is compile time error "identifier expected" .According to java language specification you cannot use the statement System.out.println("" +a); there.
 
Venkat Ramsimha
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
barry can u please suggest as how i need to surround the code

tx
venkat
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Venkat]: barry can u please suggest as how i need to surround the code

When you type the code in the message box, enclose the code with tags. Explanation on how to use the UBB code. You can edit your post by clicking on the little "pencil-and-paper" icon along the top edge of the post.
[ May 17, 2005: Message edited by: Joyce Lee ]
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic