> 
> Blockquote
> 
> 
> 

I am trying to Iterate List of Long objects and setting each value into long variable.But i am getting 

> 
> java.lang.ClassCastException :: cannot be cast to java.lang.Long
> 
> 
> 

How can I get solve this issue?

```
List<Long> listLong = new ArrayList<Long>();
listLong = SampleService.sampleList();

for(int i=0;i<listLong.size();i++){
    long sampleId = listLong.get(i).longValue();
}

```

`

```
public List<Long> sampleList() throws Exception{

    LOGGER.info("start of sampleList method ");
    List<Long> sampList = null;
    final MapSqlParameterSource params = new MapSqlParameterSource();

    final SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate)
            .withProcedureName("SAMPLE_TERM");
    simpleJdbcCall.declareParameters(new SqlOutParameter("SAMPLE_CURSER",
            OracleTypes.CURSOR, new SampleRowMapper()));

    final Map<String, Object> out = simpleJdbcCall.execute(params);

    sampList = (List<Long>) out.get("SAMPLE_CURSER");
    LOGGER.debug("List  :: "+sampList .size());

    return sampList ;

}

```

> 
> 
> 

```
java.lang.ClassCastException: com.sample cannot be cast to java.lang.Long
        at com.sample.cronTask(sample.java:49)
        at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
        at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

```