Transfer value or reference

xiaoxiao2021-03-06  55

Class REFOBJ {? public int i = 5;} public class valueorrefdeom {? public static void main (string [] cmdary) {??? valueorrefdemo demo = new valueorrefdemo (); ??? demo.init ();?}? Public void init () {??? refobj ref = new refobj (); ??? ref.i = 5; ??? INT i = 5; ??? ??? Changethem (I, REF);??? System.out.println ("---------"); ??? system.out.println ("Ref.i value:" ref.i); ??? system.out .println ("" value " i) ;?}? PUBLIC VOID CHANGETHEM (INT I, REFOBJ REF) {??? i = 9; ??? ref.i = 9; ??? system.out. Println ("Change the value of Ref.i in the function:" ref.i); ??? system.out.println ("Change the value of I in the function:" i) ;?}}

?

The output is: 9990

转载请注明原文地址:https://www.9cbs.com/read-117750.html

New Post(0)