eclipse编写java程序
packagejavaaa.huolili;importjava.util.ArrayList;publicclassArrayList{publicstaticvoid...
package javaaa.huolili;
import java.util.ArrayList;
public class ArrayList
{
public static void main(String[] args)
{
ArrayList arrayList = new ArrayList();
arrayList.add("Hello");
arrayList.add("World");
arrayList.add("World");
arrayList.add("Welcome");
String s1 = (String)arrayList.get(0);
String s2 = (String)arrayList.get(1);
String s3 = (String)arrayList.get(2);
String s4 = (String)arrayList.get(3);
System.out.print(s1);
System.out.print(s2);
System.out.print(s3);
System.out.print(s4);
}
}
运行的时候写The method get(int) is undefined for the type ArrayList
The method get(int) is undefined for the type ArrayList
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method add(String) is undefined for the type ArrayList
The method add(String) is undefined for the type ArrayList
The method add(String) is undefined for the type ArrayList
The method add(String) is undefined for the type ArrayList
The method get(int) is undefined for the type ArrayList
The method get(int) is undefined for the type ArrayList
The method get(int) is undefined for the type ArrayList
The method get(int) is undefined for the type ArrayList
at javaaa.huolili.ArrayList.main(ArrayList.java:11) 展开
import java.util.ArrayList;
public class ArrayList
{
public static void main(String[] args)
{
ArrayList arrayList = new ArrayList();
arrayList.add("Hello");
arrayList.add("World");
arrayList.add("World");
arrayList.add("Welcome");
String s1 = (String)arrayList.get(0);
String s2 = (String)arrayList.get(1);
String s3 = (String)arrayList.get(2);
String s4 = (String)arrayList.get(3);
System.out.print(s1);
System.out.print(s2);
System.out.print(s3);
System.out.print(s4);
}
}
运行的时候写The method get(int) is undefined for the type ArrayList
The method get(int) is undefined for the type ArrayList
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method add(String) is undefined for the type ArrayList
The method add(String) is undefined for the type ArrayList
The method add(String) is undefined for the type ArrayList
The method add(String) is undefined for the type ArrayList
The method get(int) is undefined for the type ArrayList
The method get(int) is undefined for the type ArrayList
The method get(int) is undefined for the type ArrayList
The method get(int) is undefined for the type ArrayList
at javaaa.huolili.ArrayList.main(ArrayList.java:11) 展开
4个回答
2015-12-01 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
类名不能用ArrayList。建议楼主先别用eclipse,用文本编辑工具吧。
更多追问追答
追问
用记事本编了好久了 这才改得eclipse
追答
我觉得javaSe的学习部分都应该用文本编辑器。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.util.ArrayList;
public class text
{
public static void main(String[] args)
{
ArrayList arrayList = new ArrayList();
arrayList.add("Hello");
arrayList.add("World");
arrayList.add("World");
arrayList.add("Welcome");
String s1 = (String)arrayList.get(0);
String s2 = (String)arrayList.get(1);
String s3 = (String)arrayList.get(2);
String s4 = (String)arrayList.get(3);
System.out.print(s1);
System.out.print(s2);
System.out.print(s3);
System.out.print(s4);
}
}
我为什么可以正常编译 结果是HelloWorldWorldWelcome
public class text
{
public static void main(String[] args)
{
ArrayList arrayList = new ArrayList();
arrayList.add("Hello");
arrayList.add("World");
arrayList.add("World");
arrayList.add("Welcome");
String s1 = (String)arrayList.get(0);
String s2 = (String)arrayList.get(1);
String s3 = (String)arrayList.get(2);
String s4 = (String)arrayList.get(3);
System.out.print(s1);
System.out.print(s2);
System.out.print(s3);
System.out.print(s4);
}
}
我为什么可以正常编译 结果是HelloWorldWorldWelcome
更多追问追答
追问
可是我的为什么报错啊 说ArrayList没有那个类 是不是我设置有什么问题
追答
你把类名字改一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这个类的类名有问题,和java自带的类名重复,换个名就可以了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询