gpt4 book ai didi

java - 使用java在方法中调用具有不同名称的字符串

转载 作者:行者123 更新时间:2023-12-01 18:40:57 24 4
gpt4 key购买 nike

我有很多具有以下名称的字符串:

String testingTest1
String testingTest2
String testingTest3

我有一个类似的方法

public void tester(TestID){}

TestID 将为 Test1、Test2、Test3

如何仅通过 Test1 来调用testingTest1?

我试过了

String TestID = "testing" + TestID

但是不起作用

最佳答案

使用 Map(Key,value) 代替,键为“Test1”、“Test2”...

关于java - 使用java在方法中调用具有不同名称的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59933343/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com