如何连接静态字符串数组 [英] How do I concatenate static string arrays

查看:155
本文介绍了如何连接静态字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何在Java中连接两个数组?

我将SET1声明为静态String [],我想将SET2声明为SET1 +其他几个参数。是否可以将SET2静态相似(即私有静态String [])声明为SET1,但使用上面的定义,如果不是如何做到这一点?

I have SET1 declared as a static String[] and I would like to declare SET2 as SET1 + few other parameters. Is it possible to declare SET2 statically similar (i.e. private static String[]) to SET1 but using the above definition, if not how to do this?

private static final String[] SET1 = { "1", "2", "3" };

SET2 = SET1 + { "4", "5", "6" };


推荐答案

看看 Commons Util ArrayUtils.add:

Look at Commons Util ArrayUtils.add:

static String[] SET2 = ArrayUtils.add(SET1, {"4", "5", "6" });

这篇关于如何连接静态字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆