• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Identifier Expected,Misplaced Constructs

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when I am compiling my program,It is giving me Identifier Expected error in the lines marked green below.


can anybody tell me why it is coming and how it can be removed?
 
Sheriff
Posts: 22268
119
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are trying to put statements directly inside your inner class. You can only put statements in constructors, methods, static initializer blocks and non-static initializer blocks.
 
Ankit Tripathi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Then why these lines are not giving error,this is also an executable code.
 
Rob Spoor
Sheriff
Posts: 22268
119
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because these are all declarations. You are allowed to initialize any variable during declaration, but they are still declarations. You are creating 7 instance variables with default (package private) visibility.
 
Ankit Tripathi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok that is fine.But my problem is something else.Please read the code snippet given below carefully.
I am developing a java program to read the values of some memory parameters from a URL and to insert them automatically in an excel sheet three times in a day.Initially I am testing it on a text file and demo code is given below.


given code is only able to create one row after headers.I have checked the value of r(indicating rows)for each run of run() method.it is increasing continously and output file(MyWorkBook) size is also increasing continously.also I tried to print FileOutputStream for each run,it is also giving me some value instead of null.
It is also confirmed that content is not overwritten for each run,because first row is giving the time of first run of run() method.
Can you suggest me if there is any error in way,I am doing the things.

the output console,data of excel sheet and input is given below.


2
java.io.FileOutputStream@b169f8
3
java.io.FileOutputStream@b169f8
4
java.io.FileOutputStream@b169f8
5
java.io.FileOutputStream@b169f8
6
java.io.FileOutputStream@b169f8
7
java.io.FileOutputStream@b169f8

//program terminated by user.




Date Time Free Memory Total Memory Max Memory No Of Processors
05-Apr-11 3:29:52 PM 1024k 522k 2099k 8




free Memory:1024k<
total Memory:522k<
max Memory:2099k<
available Processors:8<

 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic