Arraylist in Arraylist, unchecked error. Java

Im trying to put arraylists into an arraylist. Adding data to the new arrays, then print them in order. Im only getting errors. Is this the right way to create an arraylist in another arraylist using a for loop? I would also like to now how I can get data from the array in a better way then these long expresions. My errors jogging.java:101: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList res.get(iter).add(new Resultat(name,time)); jogging.java:152: warning: [unchecked] unchecked conversion found : java.util.ArrayList required: java.util.List Collections.sort(res.get(iter2)); jogging.java:152: warning: [unchecked] unchecked method invocation: sort(java.util.List) in java.util.Collections is applied to (java.util.ArrayList) Collections.sort(res.get(iter2));
    import java.util.*;
    import java.lang.*;

    class Resultat implements Comparable {

        String namn;
        double tid;

        public Resultat( String n, double t ) {
            namn = n;
            tid = t;
        }
     public String toString() 
    {
            return namn + " "+ tid;
        }

        public int compareTo( Resultat r ) {
        	
    	    if (this.tid < r.tid){
    	    return -1;
        	}
        	else if (this.tid > r.tid){
    	        	return 1;
    	              }
    	    else if (this.tid == r.tid && this.namn.compareTo(r.namn) <= 0)
         	{
    	     	return -1;
    	    }
    	    else if ( this.tid == r.tid && this.namn.compareTo(r.namn) >= 0){
    	     	return 1;
    	    }
    	    else {return 0;}
    	
    	
        }
    }



    public class jogging {
	
	    public static void main( String[] args ){
		

		    int runners = scan.nextInt();
		
		    int competitions = scan.nextInt();

		//create arraylist with arraylists within
		    ArrayList  res = new ArrayList();
		    for(int i = 0; i <= competitions; ++i){
			res.add(new ArrayList());
		    }
		

			
			
		    for (int i = 0; i

以上就是Arraylist in Arraylist, unchecked error. Java的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏