0 Replies Latest reply: Jul 12, 2011 3:34 AM by aneelkumar.boddu RSS

    How to use the add or get(calendar.Year) to add years one by one

      HI

             i want to add the every year into the list . is this code is correct or wrong .

       

            please give me a solution ..  after that i want use this YearIist in some other class

       

       

      public List<Integer> getYearList()

         {

             Calendar calendar=Calendar.getInstance();

                List<Integer> years = new ArrayList<Integer>();

                for(int num=0;num<=5;num++){

                years.add(calendar.get(Calendar.YEAR)+num);

       

                 }

                     return years;

       

         }