| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 557 人关注过本帖
标题:创建数组报错,求教!
只看楼主 加入收藏
hlhlf4
Rank: 1
等 级:新手上路
帖 子:7
专家分:2
注 册:2012-7-25
收藏
 问题点数:0 回复次数:1 
创建数组报错,求教!
自己跟着教材写了一段数组的代码,和书上的一模一样,可就是一直报错。
代码如下:

程序代码:
import java.util.ArrayList;

public class ArrayListTest {

    public static void main(String[] args) {
        
        NSMutableArray * anArray=[[NSMutableArray alloc] init];
        [anArray addObject:@"Monday"];
        [anArray addObject:@"Tuesday"];
        [anArray addObject:@"Wednesday"];
        [anArray addObject:@"Thursday"];
        [anArray addObject:@"Friday"];
        [anArray addObject:@"Saturday"];
        [anArray addObject:@"Sunday"];
        [anArray sortUsingSelector: @selector(caseInsensitiveCompare)];
        
        int count;
        count = anArray.count;
        for (int y=0; y<count; y++){
            NSLog(@"Day is %@", [anArray objectAtIndex: y]);
        }
        //Release the array
        [anArray release];
        
    }

}


报错如下:
程序代码:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    Syntax error on token "*", invalid AssignmentOperator
    Syntax error on token "[", invalid Expression
    Syntax error on token(s), misplaced construct(s)
    Syntax error on token "]", [ expected after this token
    Syntax error on token "[", delete this token
    Syntax error on token(s), misplaced construct(s)
    Syntax error on tokens, Statement expected instead
    Syntax error on tokens, delete these tokens
    Syntax error on token(s), misplaced construct(s)
    Syntax error on token "@", delete this token
    Syntax error on token "anArray", ? expected after this token
    Syntax error on token ")", ++ expected
    Syntax error on token "[", delete this token
    Syntax error on token "]", delete this token

    at ArrayListTest.main(ArrayListTest.java:21)


请问到底错在哪里?
搜索更多相关主题的帖子: 教材 
2012-10-12 02:05
hlhlf4
Rank: 1
等 级:新手上路
帖 子:7
专家分:2
注 册:2012-7-25
收藏
得分:0 
PS  我用的是mac上的eclipse
2012-10-12 18:49
快速回复:创建数组报错,求教!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015722 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved