简体   繁体   English

ArrayList 类型中的方法 set(int, Int)<int> 不适用于 arguments (int, int) 长度无法解析或不是字段</int>

[英]The method set(int, Int) in the type ArrayList<Int> is not applicable for the arguments (int, int) length cannot be resolved or is not a field

My code is showing:我的代码显示:

The method set(int, Int) in the type ArrayList is not applicable for the arguments (int, int) length cannot be resolved or is not a field ArrayList 类型中的方法 set(int, Int) 不适用于 arguments (int, int) 长度无法解析或不是字段

but I don't know how to resolve it.但我不知道如何解决它。

package revision;
import java.util.*;

public class FinalTrace {

    public static <Int> void main(String[] args) {
        // TODO Auto-generated method stub
        ArrayList <Int> list = new ArrayList <Int>();
        list.add(100, null);
        list.add(200, null);
        int num = (int) list.get(1);
        System.out.println("Number at index 1 in your arraylist: " + 
        num);
        
        **list.set(2, 500);
        System.out.print("The current numbers in your arraylist: ");
        for (int i=0; i < list.length; i++)
        System.out.print(list.get(i) + " ");
        System.out.println("\n----------------------");**

        int [] arr = new int[3];
        getValues(arr);
        System.out.print("The numbers of array that you already entered: ");
        for (int i = 0; i < arr.length; i++)
        System.out.print(arr[i] + " ");
        System.out.println("\n----------------------");

        classA obj1 = new classA();
        classA obj2 = new classC();
        classC obj3 = new classC();
        System.out.print(obj2.toString());

        System.out.println("----------------------");
        try
        {
        if (num == 200)
          throw new FinalException();
        }
        finally
        {
        FinalException e;
        System.out.println(e.getMessage());
        }
      }

Fix ArrayList <Int> list = new ArrayList <Int>() to List <Integer> list = new ArrayList <>() .修复ArrayList <Int> list = new ArrayList <Int>()List <Integer> list = new ArrayList <>() The boxed int is Integer .装箱的intInteger

Also, Collections to not have length like an array.此外, Collections 没有像数组那样的length Correct to list.size()`.更正 list.size()`。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 方法 sum(int, int, int, int) 不适用于参数 (int) - The method sum(int, int, int, int) is not applicable for the arguments (int) 类型中的方法不适用于参数(int) - The method in the type is not applicable for the arguments (int) PrintStream 类型中的方法 println(int) 不适用于参数 (String, int, int, int) - The method println(int) in the type PrintStream is not applicable for the arguments (String, int, int, int) Java Writer 错误:Writer 类型中的方法 write(char[], int, int) 不适用于 arguments (int, double, int, String) - Java Writer error: The method write(char[], int, int) in the type Writer is not applicable for the arguments (int, double, int, String) 错误 java 方法组合Sum(int[], int, List<integer> ) 类型中的解决方案不适用于 arguments (int[], int, boolean)</integer> - error java The method combinationSum(int[], int, List<Integer>) in the type Solution is not applicable for the arguments (int[], int, boolean) FragmentTransaction类型的方法add(int,Fragment)不适用于参数(int,WeatherFragment) - The method add(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, WeatherFragment) BufferedImage类型的方法getRGB(int,int)不适用于参数(..) - The method getRGB(int, int) in the type BufferedImage is not applicable for the arguments (..) prosedure_jsp类型的pro(int,int)方法不适用于参数() - The method pro(int, int) in the type prosedure_jsp is not applicable for the arguments () Arrays 类型中的 asList(T[]) 方法不适用于参数 (int, int) - The method asList(T[]) in the type Arrays is not applicable for the arguments (int, int) PreparedStatement 类型中的 setString(int, String) 方法不适用于参数 (int, String[]) - The method setString(int, String) in the type PreparedStatement is not applicable for the arguments (int, String[])
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM