Results 1 to 3 of 3

Thread: ArrayList issue

  1. #1
    tomrobpowell is offline Member
    Join Date
    May 2010
    Posts
    1
    Rep Power
    0

    Question ArrayList issue

    Hello,

    While trying to complete an Android tutorial I came across an error that meant I couldnt complete it. I've reproduced it using base Java classes in Eclipse. The code is below

    Java Code:
    package com.example.hellogooglemaps;
    
    import java.util.AbstractList;
    
    private ArrayList<int> mint = new ArrayList<int>();
    
    
    public class HelloProveProblem {
    
    	public HelloProveProblem() {
    		//*do nothing really
    		}
    
    }
    The error is where
    Java Code:
    mint
    is being created.

    I get the following errors:

    Description Resource Path Location Type
    Syntax error on token "private", interface expected after this token HelloProveProblem.java /HelloGoogleMaps/src/com/example/hellogooglemaps line 5 Java Problem

    and

    Description Resource Path Location Type
    Syntax error on tokens, delete these tokens HelloProveProblem.java /HelloGoogleMaps/src/com/example/hellogooglemaps line 5 Java Problem

    Help!

    Tom

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    If the code you posted is accurate, it appears if you have code sitting outside of a class -- the ArrayList declaration and initialization -- and that just isn't kosher.

  3. #3
    gbtimmon is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default

    On top of that, generics in java do not support primitive types.
    you need to use the Integer class, rather than the int primitive type

    private ArrayList<Integer> mint = new ArrayList<Integer>();

Similar Threads

  1. Having an issue with this
    By baap30 in forum New To Java
    Replies: 5
    Last Post: 04-23-2010, 06:32 AM
  2. nio issue
    By mawandiadeepak in forum Networking
    Replies: 2
    Last Post: 03-17-2010, 06:23 AM
  3. JSF issue
    By premjo in forum New To Java
    Replies: 0
    Last Post: 02-14-2010, 03:19 PM
  4. Issue
    By FlashNinja in forum New To Java
    Replies: 20
    Last Post: 11-28-2009, 10:44 PM
  5. Replies: 2
    Last Post: 04-21-2008, 12:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •