• 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

help me in kicking off the bug from the following code

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
while compiling the following code, an error occurs and what could b the soln to resolve this code. thanx.
abstract class second {
int i;
abstract void setValue (int);
int getValue () {
return i;
}
abstract void printValue ();
}
public class first extends second {
static first f = new first();
public first() {
}
static public void main(String[] args) {
System.out.println("Hello");
f.setValue (10);
f.printValue();
}
void setValue (int iValue) {
i = iValue;
}
void printValue () {
System.out.println("Value of i ::: " + f.getValue ());
}
}
 
author
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. What is the error?
2. What do you think the problem is?
 
author
Posts: 799
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I received these errors:

when I compiled the program.
Suggestions/questions:
* post in the beginner's forum next time
* what do you think "<identifier> expected" means?
* format your code to make it easier to follow. Start by reading Sun's coding conventions at http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html. For example, the class names should be First and Second, not first and second.
* when posting code here, use the appropriate code tags
The fix to get the code to compile is very simple. Hint: the method signature is missing something. Good luck.
Jeff
[ March 11, 2004: Message edited by: Jeff Langr ]
 
Akshay Kumar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx for the response.
can't i specify the parameter's type alone, as a part of the signature. why shld i also give some identifier to it?
in C or C++, the parameter's type in the declaration is suufice but why it is not in java?
 
David Peterson
author
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good question. It helps to document the method if you give descriptive variable names in the abstract class. E.g. compare these two declarations:
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic