I am writing a simple code snippet. I have created an ArrayList and add( new Integer( some int value ) ) to the ArrayList. When I index through the ArrayList, I try to convert Integer back to int and print it out, I have "cannot find symbol: method intValue()" compilation error. How do I fix my code? Thank you.
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.List;
import java.util.ArrayList;
public class FindOffsetsInArrayList
{
public static void main(String[] args)
throws Exception
{
List offsets = new ArrayList();
// Create a pattern to match foundEntity
Pattern p = Pattern.compile("Italy");
// Create a matcher with an input msgStr
Matcher m = p.matcher( "Victor visited Italy in 1991. While he was in Italy, he had a good time." );
while ( m.find() )
{
offsets.add( new Integer( m.start() ) );
}
System.out.println("Retriving all offsets from the ArrayList");
for ( int i = 0; i < offsets.size(); i++ )
{
System.out.println( ( offsets.get( i ) ).intValue() ); // where the compilation error occurs
}
}
}