| Author |
Doubts regarding ArrayLists
|
sagar shiraguppi
Ranch Hand
Joined: Jul 16, 2007
Posts: 74
|
|
class ArrayListDemo1 {
public static void main(String args[]) {
// create an ArrayList
ArrayList arl = new ArrayList();
System.out.println("Initial size of ArrayList: " + arl.size());
// adding dissimilar elements to the ArrayList
arl.add("C");
arl.add("A");
arl.add("E");
arl.add("B");
arl.add("D");
arl.add("F");
arl.add(1, "A2");
arl.add(null);
System.out.println("Size of ArrayList after additions: " + arl.size());
// display the ArrayList
System.out.println("Contents of ArrayList: " + arl);
// Remove elements from the ArrayList
arl.remove("F");
arl.remove(2);
System.out.println("Size of ArrayList after deletions: " + arl.size());
System.out.println("Contents of ArrayList after deletions: " + arl);
}
}
I am getting java runtime error in eclipse, I am not able to get the output of this program, please let me know the solution for this issue. Thanks in advance.
|
 |
W. Joe Smith
Ranch Hand
Joined: Feb 10, 2009
Posts: 710
|
|
|
Can you post the error that you are getting? It will help in figuring out the issue.
|
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
|
 |
sagar shiraguppi
Ranch Hand
Joined: Jul 16, 2007
Posts: 74
|
|
When I click on run in eclipse I am gettting "A java exception error occured message" after clicking on "ok" in that message, I am getting another message saying "Error:JNi error has occured, please check your installation or try again later".
But I can restart the eclipse and run other programs, but when I run this program, I get the above errors which I mentioned and I need to restart the eclipse to run other programs as well.
|
 |
Shanky Sohar
Ranch Hand
Joined: Mar 17, 2010
Posts: 1047
|
|
Could you please use CODETAGS while posting your question.your Question would be easier to read then.
I think problem should be the retriving the null.
and also how can you print the contents of array without using any loop.
|
SCJP6.0,My blog Ranchers from Delhi
|
 |
W. Joe Smith
Ranch Hand
Joined: Feb 10, 2009
Posts: 710
|
|
|
That may be an Eclipse error and not a code error. Once I added the ArrayList import this code ran fine, other than giving me warnings abour adding a raw type to the ArrayList.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
|
That error would indicate that your Eclipse installation -- or perhaps your Java installation itself -- are badly broken. It has nothing to do with this program that you're running. Your best course of action would be to find somebody local who can sit at your computer and help you sort that out.
|
[Jess in Action][AskingGoodQuestions]
|
 |
sagar shiraguppi
Ranch Hand
Joined: Jul 16, 2007
Posts: 74
|
|
Thank you all.
sorry for the disturbance, I was really worried, now it is fine.
Issue is resolved, Just restarted the laptop.
|
 |
Shanky Sohar
Ranch Hand
Joined: Mar 17, 2010
Posts: 1047
|
|
there is some problem in your eclipse java library..may be it is not there.
try checking your build path whether it exist or not
|
 |
 |
|
|
subject: Doubts regarding ArrayLists
|
|
|