Re: please help me
- From: Lew <lew@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 30 Apr 2007 09:55:10 -0400
mak wrote:
Hi , I am mak and i have a great problem with a java application . May
i hava your help , please?The program is called INCRTest.java and
calls class INCR.java.The main program sums an increment value and
puts it into a variable called total.
INCRTest.java is as follows:
public class INCRTest{
public static void main(String[] args){
INCR value=new INCR(5);
System.out.printf("prin ayxhthei : %s\n\n",value);
for(int i=1;i<=3;i++){
value=addINCRToTotal();
System.out.printf("meta thn ayxhsh %d: %s\n",i,value);
}
}
}
, INCR.java is as follows:
public class INCR{
private int total=0;
private final int INCREMENT;
public INCR(int incrementValue){
INCREMENT= incrementValue;
}
public void addINCRToTotal(){
total+=INCREMENT;
}
public String toString(){
return String.format("total= %d",total);
}
}
Compliler says that he 'cannot find symbol method addINCRToTotal()'
You should /copy/ and /paste/ the /entire/ error message. In this case, though, the answer is obvious. You invoked
value=addINCRToTotal();
which embodies three errors:
1) addINCRToTotal() was not invoked through an owning object.
2) addINCRToTotal() does not return anything, therefore you cannot put it in an expression such as an assignment.
3) value is an object of type INCR (better to name that class Incr, btw) and not of what you probably thought the return type of addINCRToTotal() should have been (were it not void).
The compiler error was your clue - you have defined no symbol addINCRToTotal() in the context of the test class.
--
Lew
.
- References:
- please help me
- From: mak
- please help me
- Prev by Date: please help me
- Next by Date: Tomcat - One login only
- Previous by thread: please help me
- Next by thread: Tomcat - One login only
- Index(es):
Relevant Pages
|
|