Php array value transfer call and address transfer call
Public class ArrayTest {
- Public static void main (String [] args ){
- Map [] maparray = new Map [3];
- For (int I = 0; I <maparray. length; I ++ ){
- Map Map = new HashMap ();
- Map. put ("a", I + "_ ajkcz ");
- Map. put ("c", "werq _" + I );
- Maparray [I] = map;
- }
-
- System. out. println ("++ ");
- For (int I = 0; I <maparray. length; I ++ ){
- Map Map = maparray [I];
- Iterator it = map. keySet (). iterator ();
- While (it. hasNext ()){
- String key = (String) it. next ();
- System. out. println (key + "\ t" + map. get (key ));
- }
- }
-
- System. out. println ("++ ");
- New ArrayCharge (). printAndChangeArray (maparray );
-
-
- System. out. println ("++ ");
- For (int I = 0; I <maparray. length; I ++ ){
- Map Map = maparray [I];
- Iterator it = map. keySet (). iterator ();
- While (it. hasNext ()){
- String key = (String) it. next ();
- System. out. println (key + "\ t" + map. get (key ));
- }
- }
- }
- }
Class ArrayCharge {
- Public void printAndChangeArray (Map [] maparray ){
- For (int I = 0; I <maparray. length; I ++ ){
- Map Map = maparray [I];
- Map. put ("a", I + "________");
- }
-
- For (int I = 0; I <maparray. length; I ++ ){
- Map Map = maparray [I];
- Iterator it = map. keySet (). iterator ();
- While (it. hasNext ()){
- String key = (String) it. next ();
- System. out. println (key + "\ t" + map. get (key ));
- }
- }
- }
- }
-
Console output result:
- $ Arraytest = array ();
- For ($ I = 0; $ I <3; $ I ++ ){
- $ Child = array ();
- $ Child ['keystr'] = 'key'. $ I;
- $ Child ['valuestr'] = 'value'. $ I;
- $ Arraytest [] = $ child;
- }
-
- Print_r ($ arraytest );
-
- Print_r ("++ ");
- For ($ I = 0; $ I $ Child = $ arraytest [$ I];
- $ Child ['valuestr'] = "_________". $ I;
- }
-
-
- Print_r ($ arraytest );
-
- Print_r ("++ ");
-
- ?>
-
Console output:
- $ Arraytest = array ();
- For ($ I = 0; $ I <3; $ I ++ ){
- $ Child = array ();
- $ Child ['keystr'] = 'key'. $ I;
- $ Child ['valuestr'] = 'value'. $ I;
- $ Arraytest [] = $ child;
- }
-
- Print_r ($ arraytest );
-
- Print_r ("++ ");
- For ($ I = 0; $ I $ Child = & $ arraytest [$ I]; // note that a pointer symbol is added here to indicate that the address is called.
- $ Child ['valuestr'] = "_________". $ I;
- }
-
- Print_r ($ arraytest );
- Print_r ("++ ");
- ?>
-
Console output: Array ([0] => Array ([keystr] => key0 [valuestr] => value0) [1] => Array ([keystr] => key1 [valuestr] => value1) [2] => Array ([keystr] => key2 [valuestr] => value2 )) ++ Array ([0] => Array ([keystr] => key0 [valuestr] => _________ 0) [1] => Array ([keystr] => key1 [valuestr] => _________ 1) [2] => Array ([keystr] => key2 [valuestr] => _________ 2 )) ++ |