Solved

casting a Arraylist

Posted on 2011-09-19
5
305 Views
Last Modified: 2012-05-12
I am calling a ArrayList from a different class.  Once I get the ArrayList in this class, I want to cast it to a TCComponentItemRevision

Here is the constructor
 public SelectedTModel() {
      super();
     ArrayList<RevDataset> aList = EdiSelection.rds;
}

Open in new window


Then I am using the ArrayList in a method
 public void getListValues(int row, int column, ArrayList <RevDataset> aList) throws TCException {

Open in new window


But I need to cast the ArrayList to  TCComponentItemRevision
0
Comment
Question by:jkteater
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 75 total points
ID: 36561964
Waht you meant by casting ArryList?

You iterate through ArrayList and retrieve its ellemnts of type RevDataset
and then get from these elements using their get methods each of their compounents which are TCCiomponent isf I rememeber correctly
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36561974
Waht type expects your method in that third position ?
0
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 50 total points
ID: 36562000
you can only cast it to TCComponentItemRevision if ArrayList is extending that class or implementation, otherwise you need to loop through the list elements and then convert it one by one
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36562033
Theis method probably expects only one elemnt of your ArrayList and even maybe one part of it,
as the elements are the objects whiach are made up of two fileds, if I am not mistaken.

Show what is within that method  and we'll try to figure out
0
 

Author Comment

by:jkteater
ID: 36562082
I went back to where I was creating the ArrayList and cast it there - So I am going to split the points - thanks for the quick response
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java exception bubble up 2 26
Java: The Public Class Main 4 66
Notify sent to other threads in Java 9 54
Html Table Looping (part 2) 5 41
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question