Here lies the problem:
>     // Another static method in the TestPassByValue class
>     public static void test(int j, long m){

there are two values passing to a method body.
and when You are using this method, you write test(i)
so thats the problem: pass either two values or one value for both
types.

Regards
Grzegorz Patynek
On Aug 8, 8:22 pm, "tinyang" <[email protected]> wrote:
> Hello
>
> I am trying to complete 3.1 of Lab 1011.  Below is 3.1:
>
> 4. (For your own exercise) Modify TestPassByValue.java as following.  Build
> and run the project.
>
> *       Pass the second primitive type parameter to the test(..) method -
> you can choose any primitive type parameter (such as long or boolean).
> *       Set the value of the second parameter before calling the test(..)
> method.  And change the value of the passed parameter within the test(..)
> method as you did with the first parameter in Code-3.11 above.
> *       Modify the System.out.println(..) methods in the Code-3.11 above to
> display the values of both the first parameter and second parameter.
>
> Here is my code:
>
> public class TestPassByValue {
>
>     /**
>      * @param args the command line arguments
>      */
>     public static void main(String[] args) {
>         // TODO code application logic here
>         int i = 10;
>         long k = 500;
>
>         // Print the value of i
>         System.out.println("start of the main method and i = " + i);
>         System.out.println("start of the main method and k = " + k);
>
>         // Call method test, which is defined below
>         // and pass int value as a parameter.  Since
>         // int is a primitive type, this parameter is passed
>         // by value.
>         test( i );
>         test( k );
>
>         // print the value of i. please note that  i not changed
>         System.out.println("end of the main method and i = " + i);
>         System.out.println("end of the main method and k = " + k);
>     }
>
>     // Another static method in the TestPassByValue class
>     public static void test(int j, long m){
>
>         System.out.println("start of the test method and j = " + j);
>         System.out.println("start of the test method and m = " + m);
>
>         // change value of parameter i
>         j = 33;
>         m = 501;
>
>         System.out.println("end of the test method and j = " + j);
>         System.out.println("end of the test method and m = " + m);
>     }
>
> }
>
> It indicates errors for the following lines
> test( i );
> required Int, long
> found: int
>
> test( k );
> required Int, long
> found: int
>
> Shouldn't it be able to accept either int or long?  Thanks for any help.
>
> --
> :-)
> P Please don't print this e-mail unless you really need to.

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to