Results 1 to 5 of 5
- 03-29-2011, 07:05 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 44
- Rep Power
- 0
having problem with returning an interface with two method
HI, I am having problem with return methods in an interface. I was wondering if anyone will be able to let me know what i have to type in an interface since there isn't parameter is illegal.
//(2) StudentStatisticCalculator.java
//An interface with two methods:
//getName(), which returns a String
//computeStatistic(Student[] students), which returns a double
public class Student{
String name;
double gpa;
public String getName(){
return name;
}
public double getGPA() {
return gpa;
}
}
public interface StudentStatisticCalculator{
public String getName();
String name=name;
public double computeStatistic(Student[]student();
return computestatistic;
}
following error:
StudentStatisticCalculator.java:15: ')' expected
public double computeStatistic(Student[]student();
^
StudentStatisticCalculator.java:15: illegal start of type
public double computeStatistic(Student[]student();
^
StudentStatisticCalculator.java:15: <identifier> expected
public double computeStatistic(Student[]student();
^
StudentStatisticCalculator.java:16: = expected
return computestatistic;
^
StudentStatisticCalculator.java:16: ';' expected
return computestatistic;
^
5 errors
- 03-29-2011, 07:11 AM #2
Senior Member
- Join Date
- Nov 2010
- Location
- Delhi
- Posts
- 135
- Blog Entries
- 1
- Rep Power
- 0
Please go through the basics of Interface, things will become clear on its own.
You are making some very basic mistakes.
- 03-29-2011, 07:17 AM #3
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
As lovelesh said, these are basic basic mistakes, I suggest you start with
Trail: Learning the Java Language (The Java™ Tutorials)
- 03-29-2011, 07:29 AM #4
Member
- Join Date
- Mar 2011
- Posts
- 44
- Rep Power
- 0
So I was able to fixed up the getName but the other method I have no idea.
//(2) StudentStatisticCalculator.java
//An interface with two methods:
//getName(), which returns a String
//computeStatistic(Student[] students), which returns a double
public interface StudentStatisticCalculator{
public void getName();
public void computeStatistic(Student[]student());
}
}
StudentStatisticCalculator.java:14: ')' expected
public void computeStatistic(Student[]student());
^
StudentStatisticCalculator.java:14: illegal start of type
public void computeStatistic(Student[]student());
^
StudentStatisticCalculator.java:14: <identifier> expected
public void computeStatistic(Student[]student());
^
StudentStatisticCalculator.java:14: = expected
public void computeStatistic(Student[]student());
^
StudentStatisticCalculator.java:14: ';' expected
public void computeStatistic(Student[]student());
^
5 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
Where will i be able to look up basic of interface anyway?
- 03-29-2011, 07:34 AM #5
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
Be careful.
The comment:
Java Code://(2) StudentStatisticCalculator.java //An interface with two methods: //getName(), which returns a String //computeStatistic(Student[] [color=blue][b]students[/b][/color]), which returns a [color=red][b]double[/b][/color]
The code:
Java Code:public [color=red][b]void[/b][/color] computeStatistic(Student[][color=blue][b]student()[/b][/color]);
These things can be confusing at first - keep your textbooks and notes handy!
Similar Threads
-
My method keeps returning 0
By ToolJob in forum New To JavaReplies: 11Last Post: 03-27-2011, 05:22 PM -
Returning Value from a method
By Mirix in forum New To JavaReplies: 12Last Post: 06-01-2010, 09:48 PM -
Inherited method returning bad value
By viking90 in forum New To JavaReplies: 11Last Post: 04-07-2010, 03:53 PM -
returning an object from a method
By bigj in forum New To JavaReplies: 7Last Post: 01-08-2010, 12:39 PM -
Need help. Method won't returning proper value..
By zlwilly in forum New To JavaReplies: 2Last Post: 12-02-2008, 09:44 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks