2014年5月26日星期一

Help cannot be resolved to a variable

 This post last edited by int_java_se on 2014-05-25 18:49:33
public class Encapsulation
{
public int add (int a, int b)
{
return a + b;
}
public int subtract (int a, int b)
{
return a - b;
}
public int multiplication (int a, int b)
{
return a * b;
}
public int division (int a, int b)
{
return a / b;
}
public void sop () / / here is no need to return , the variable name must be familiar with the following variable names are case unity.
{
System.out.println ("hello word");
}
public void returnTest (int x)
{
for (int f = 1; f <10; f + +)
{
if (9 == f)
{
System.out.println (x + "=" + f);
}
}
System.out.println (x);
}
public static void main (String [] args)
{
Encapsulation test = new Encapsulation ();
int a = 8;
int b = 4;
int i = test.add (a, b) ;/ / method calls need to be completed by the object , the method call in the form of : object variable method name ( [ parameter 1 , parameter 2 , parameter 3 .... ) ;
int i1 = test.subtract (a, b);
int i2 = test.multiplication (a, b);
int i3 = test.division (a, b);
System.out.println (i);
System.out.println (i1);
System.out.println (i2);
System.out.println (i3);
test.sop ();
testreturnTest (x); / / error of x cannot be resolved to a variable Editor's Note it

}
}
------ Solution ----------------------------------- ---------
testreturnTest(x); 

What's this ?
1, x is not defined .
2, testreturnTest what stuff .
------ Solution ---------------------------------------- ----
you do not define the variable x course not , public void returnTest previously defined (int x) {} where x is only reurnTest () function in Useful
------ For reference only ------------------------------------- -
X variable , you define where ? ?
------ For reference only -------------------------------------- -
I only declare int is not assigned .
------ For reference only -------------------------------------- -
x?
------ For reference only ---------------------- -----------------
x lie ? landlord or call the compiler about Caesar , x you are passed as arguments , you do not define x, you dare pass ?
------ For reference only ---------------------------------------
; public void returnTest (int x)
{
for (int f = 1; f <10; f + +)
{
if (9 == f)
{
System.out.println (x + "=" + f);
}
}
System.out.println (x);
}
there any way to get X return out , ah, do not define you?
------ For reference only -------------------------------------- -
x this variable is not defined that way

没有评论:

发表评论