What is IllegalStateException?

前端 未结 4 2511
借酒劲吻你
借酒劲吻你 2020-12-09 08:12

I am trying to use the following Fastload API

connection ... etc is perfect.


I know exactly where it fails

 ...........
 System.out.pr         


        
4条回答
  •  余生分开走
    2020-12-09 08:53

    package com.concepttimes.java;
    
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    
    public class IllegalStateExceptionDemo {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            List al = new ArrayList();
            al.add("Sachin");
            al.add("Rahul");
            al.add("saurav");
            Iterator itr = al.iterator();  
            while (itr.hasNext()) {           
                itr.remove();
            }
        }
    }
    

    IllegalStateException signals that method has been invoked at the wrong time. In this below example, we can see that. remove() method is called at the same time element is being used in while loop.

    Please refer to below link for more details. http://www.elitmuszone.com/elitmus/illegalstateexception-in-java/

提交回复
热议问题