Java 如何将arraylist返回为ints

Java 如何将arraylist返回为ints,java,Java,我试图创建一个数组,该数组从某个数字开始,根据传入的参数执行x次,然后递增以添加另一个数字。我已正确创建数组,但必须返回数组。我查阅了一些视频和文章,但都搞不懂。 示例createArray(0,5,3)将返回一个数组,其中包含{0,3,6,9,12}以数字0开头,然后添加3,依此类推,使数组长度为5。 我得到的错误是错误: 不兼容的类型:ArrayList无法转换为int 类实用程序{ 公共静态void main(字符串[]args){ //TESTcreateArray(1,3,2); }

我试图创建一个数组,该数组从某个数字开始,根据传入的参数执行x次,然后递增以添加另一个数字。我已正确创建数组,但必须返回数组。我查阅了一些视频和文章,但都搞不懂。 示例createArray(0,5,3)将返回一个数组,其中包含{0,3,6,9,12}以数字0开头,然后添加3,依此类推,使数组长度为5。 我得到的错误是错误:

不兼容的类型:ArrayList无法转换为int

类实用程序{
公共静态void main(字符串[]args){
//TESTcreateArray(1,3,2);
}
公共静态int-createArray(int-start、int-count、int-step){
int i=0;
int startingNumber=开始;
int增量=步长;
ArrayList arrList=新的ArrayList();
//int x=arrList;
而(i改变你的:

public static int createArray(int start, int count, int step)
致:

publicstaticarraylistcreatearray(int-start、int-count、int-step)

该方法的返回类型不正确。您必须将其更改为ArrayList错误消息非常清楚:ArrayList无法转换为int3.5 weeks到Java,因此仍在学习,但即使将其转换为公共静态ArrayListcreateArray(int start、int count、int step){它仍然没有通过我的讲师测试,但是当我打印数组时,它的结果是正确的。谢谢,我发现在我发布这个之后,我立即发布了公共静态ArrayListcreateArray(int start,int count,int step){但是它仍然没有通过我的讲师测试,但是打印正确。很高兴能提供帮助
public static int createArray(int start, int count, int step)
public static ArrayList<Integer> createArray(int start, int count, int step)