我如何组合这两个变量? [英] How do I combine these two variables?

查看:100
本文介绍了我如何组合这两个变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将两个变量Variable1和Variable2合并在一起,但我无法将它们合并。



这是一个单独的类java文件:

Hi, I want to merge the two variables Variable1 and Variable2 together, but I couldn't merge them.

This is a separate class java file:

public class AnswerList {
	private int mQuestion;
	private int mAnswer;
	private int mChoice1;
	private int mChoice2;
	private int mChoice3;
	private int mChoice4;

public AnswerList(int question, int choice1, int choice2, int choice3, int choice4, int answer){
		mQuestion = question;
		mAnswer = answer;
		mChoice1 = choice1;
		mChoice2 = choice2;
		mChoice3 = choice3;
		mChoice4 = choice4;
	}









我必须申报两个变量分开,因为我想只在满足某些条件时才将两者结合起来。我遇到的问题是我无法使合并工作。





I have to declared the two variables separately because I want to combine the two only if certain conditions are met. The issue I have is I can't get the combining to work.

private AnswerList[] Variable1 = new AnswerList[] {
			new AnswerList(R.string.question1, R.string.answerone1,
					R.string.answerone2, R.string.answerone3,
					R.string.answerone4, 4),
			new AnswerList(R.string.question2, R.string.answertwo1,
					R.string.answertwo2, R.string.answertwo3, R.string.answertwo4, 2)};

private AnswerList[] Variable2 = new AnswerList[]{
            new AnswerList(R.string.question5, R.string.answerfive1,
                    R.string.answerfive2, R.string.answerfive3,
                    R.string.answerfive4, 1)
            };











我试图使用以下代码合并它们,但它们都没有用。我究竟做错了什么?谢谢!



我想得到最终结果:






I tried to used the following codes to merge them, but none of them worked. What am I doing wrong? Thanks!

I want to get the final result to be like this:

private AnswerList[] Variable1 = new AnswerList[] {
			new AnswerList(R.string.question1, R.string.answerone1,
					R.string.answerone2, R.string.answerone3,
					R.string.answerone4, 4),
			new AnswerList(R.string.question2, R.string.answertwo1,
					R.string.answertwo2, R.string.answertwo3, R.string.answertwo4, 2),
           new AnswerList(R.string.question5, R.string.answerfive1,
                    R.string.answerfive2, R.string.answerfive3,
                    R.string.answerfive4, 1)};



注意:我是Java / Android初学者。




Note: I am a Java/Android beginner.

Arrays mergevariables = ArrayUtils.addAll(Variable1,Variable2);
Collections.addAll(Variable1,Variable2);

推荐答案

我已经在Java论坛中给你一个建议;请不要重新发布。
I already gave you a suggestion in the Java forum; please do not repost.


这篇关于我如何组合这两个变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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