假设我有两个字符串,如下所示:
String name = "EXAMPLE_MODEL_1";
String actionName = "ListModels";
我想要如下所示的结果字符串:
String result = "ExampleModel1ListModels";
我尝试了 Follwoing 代码:
String result = name.toLowerCase().replaceAll("_", "");
result = result.concat(actioName);
我得到的结果值为“examplemodel1ListModels”。但预期的是“ExampleModel1ListModels”。
最佳答案
name
字符串需要替换下划线——您已经做到了。在此之前,您需要 convert it to title case .
之后,只需连接两个字符串即可。
关于java - Java中如何修改这个String?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8997935/