*
The moose likes Java in General and the fly likes help me in kicking off the bug from the following code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "help me in kicking off the bug from the following code" Watch "help me in kicking off the bug from the following code" New topic
Author

help me in kicking off the bug from the following code

Akshay Kumar
Ranch Hand

Joined: Feb 24, 2004
Posts: 37
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 ());
}
}
David Peterson
author
Ranch Hand

Joined: Oct 14, 2001
Posts: 154
1. What is the error?
2. What do you think the problem is?
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
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 ]

Books: Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Akshay Kumar
Ranch Hand

Joined: Feb 24, 2004
Posts: 37
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
Ranch Hand

Joined: Oct 14, 2001
Posts: 154
Good question. It helps to document the method if you give descriptive variable names in the abstract class. E.g. compare these two declarations:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help me in kicking off the bug from the following code
 
Similar Threads
Small OO doubt
Casting from double to int leading to in correct data for very specific numbers
What is the output for the below code is different?
help me in kicking off the bug from the following code
Concurrency Question with Thread.sleep(5000) ?