473,324 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

ArrayList methods

281 100+
Kindly please someone who knows how to get last Entry in ArrayList?
Please share with me..thanks

Expand|Select|Wrap|Line Numbers
  1. void methodA
  2. { ....
  3. while ( myArrayList. ??? ) // how to get the last Entry? 
  4.    // in last Entry of ArrayList need to call methodB
  5. }
Apr 16 '07 #1
4 6680
r035198x
13,262 8TB
Kindly please someone who knows how to get last Entry in ArrayList?
Please share with me..thanks

Expand|Select|Wrap|Line Numbers
  1. void methodA
  2. { ....
  3. while ( myArrayList. ??? ) // how to get the last Entry? 
  4. // in last Entry of ArrayList need to call methodB
  5. }
Go to the ArrayList docs and see the methods there.
Apr 16 '07 #2
shana07
281 100+
Go to the ArrayList docs and see the methods there.
sorry, kindly please give hint to me at least answer is this possible to achieve?
Expand|Select|Wrap|Line Numbers
  1. the last entry in ArrayList {
  2. //calls other method.
I found: one method, but I think that's not what I want - the object o part.
Expand|Select|Wrap|Line Numbers
  1.  firstArrayList.lastIndexOf(Object o)
Apr 17 '07 #3
r035198x
13,262 8TB
sorry, kindly please give hint to me at least answer is this possible to achieve?
Expand|Select|Wrap|Line Numbers
  1. the last entry in ArrayList {
  2. //calls other method.
I found: one method, but I think that's not what I want - the object o part.
Expand|Select|Wrap|Line Numbers
  1.  firstArrayList.lastIndexOf(Object o)
The get method gives you the option of providing the position. get(int i).
No all you need is to provide the last position of the Arraylist ...
Apr 17 '07 #4
Kindly please someone who knows how to get last Entry in ArrayList?
Please share with me..thanks

Expand|Select|Wrap|Line Numbers
  1. void methodA
  2. { ....
  3. while ( myArrayList. ??? ) // how to get the last Entry? 
  4.    // in last Entry of ArrayList need to call methodB
  5. }

try this code

ArrayList list = new ArrayList();
list.add("a");
list.add("b");
list.add("s");
list.add("S");
list.add("F");
list.add("a");
list.add("h");

int size = list.size()-1;
System.out.println("last element " +list.get(size));

regards
Kulbir Singh
Apr 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Omer | last post by:
Hi All, We are trying to invoke EJB methods on simple stateless session beans from an Applet running remotely. One of our methods needs to return an ArrayList of Serializable objects. We...
7
by: WildHare | last post by:
If I have a class and I add it to an ArrayList and then want to access that class using using the index operator (e.g. ArrayList) the ArrayList returns a type "Object". I can cast the return to...
4
by: Hans De Schrijver | last post by:
I have a private ArrayList variable that holds objects of various types, though they're all derived from a common base class (User). What I would like to do is provide public accessor properties...
4
by: Dot net work | last post by:
I thought I'd be clever and create my own strongly typed array list, because I wanted to be sure that when an object was added to the arraylist, it would *only* be an object of a class that I had...
14
by: Mike | last post by:
I had a question about threading and access to private class variables. I am developing a windows service which has a class inside of it which will receive various asynchronous calls to it via...
16
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just...
20
by: Dennis | last post by:
I use the following code for a strongly typed arraylist and it works great. However, I was wondering if this is the proper way to do it. I realize that if I want to implement sorting of the...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
1
by: KK | last post by:
Dear All I have a class whose methods are getting called from multiple threads in my application. For example class DataDistribution { private ArrayList datset; public DataDistribution() {...
20
by: cowboyrocks2009 | last post by:
Hi, I need help to automate my code to take data from input file. Also I need to create it as a function so that I can pass it to some other program. I am new to Java so having a bit limitation to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.