简体   繁体   中英

How to create an instance with the name from a string

So, I need an Instance on my class company. That's easy

public Company company1 = new Company();

Well, how do you create an instance with the name from a string like

public String companyName = "Google"
public Company [the companyName String as.. thisthing] = new Company();`

or something... or something...

您想将对象放在ArrayList以访问所有对象,而不是尝试通过字符串值命名它们

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM