Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to reference Java basic types and objects

Shulou Source: shulou.com Published: 2022-06-01 23:16:09 09月11日 Update

This article introduces the relevant knowledge of "how to quote the basic types and objects of Java". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Public class Pets {public static void printPets () {ArrayList arr = new ArrayList (); arr.add ("111"); arr.add (" 222"); favourtePets (arr); System.out.println (arr);} private static void favourtePets (ArrayList arr) {ArrayList arrNew = new ArrayList (); arrNew.add ("333"); arrNew.add ("444") ArrNew.add; arr = arrNew;} public static void main (String [] args) {printPets () / / output result: [111222] / / the reason is that the parameter is passed on the basic type value and the reference of the object is actually the address on the copy stack (similar to the basic type) / / then the arr inside the favourtePets method is only a copy of the reference value of the original object, pointing to a copy of the address of the original queue, and you can manipulate the original queue Add, delete, modify / / but the modification of the parameters will not affect the original value}} "how to reference Java basic types and objects" content is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Object type content parameter more knowledge queue output practical learned next copy reason dilemma address actual situation copy point article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Huawei MariaDB OPPO Reno vpn