Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Cannot Find Symbol intValue();

843789Sep 25 2009 — edited Sep 25 2009
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
	    }
	}
}

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 23 2009
Added on Sep 25 2009
5 comments
1,408 views