Skip to main content

All Questions

Tagged with
1 vote
5 answers
1k views

How to type-cast a nested Array of Objects into a nested List of Strings

Cannot create nested ArrayList from Array in Java I am trying to create a nested list from an array. But I have a problem while converting Object to String: Object[] array = new Object[] { ...
user avatar
2 votes
3 answers
2k views

Special Scenario : java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;

I am simply trying to remove below exception. java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String; Please help me out here. I need to cast it as List<String[]>....
Sidharth K.Burnwal's user avatar
-2 votes
1 answer
71 views

How to fix unchecked type cast [duplicate]

I am having trouble with unchecked casting. I know this happens because T is an Object but not every Object is a T. My question is how would I fix this to implement T in ArrayList<T> without ...
Tim Davis's user avatar
1 vote
2 answers
2k views

Java can't get object to cast from file to arraylist

I'm trying to load an object in from a file. I first create the file by saving an object to it. If I save only one object to a file I can get it loaded in by casting the object into a variable stead ...
user3369825's user avatar
1 vote
3 answers
2k views

Can't convert from Object to List, but it already is a List?

I can't seem to wrap my head around why the compiler is telling me that is can't convert from Object to List but it already is a List. Could someone point out what I'm not seeing? import java.util....
Frank Gallagher's user avatar
0 votes
1 answer
35 views

adding in a ArrayList by casting an Object, from table of Objects, into double

Why the cast (double) doesn't work ? I nead to add doubles to my ArrayList. import java.util.ArrayList; import java.util.ListIterator; public class Vecteur extends ArrayList implements Cloneable{ ...
Simo's user avatar
  • 161
2 votes
4 answers
121 views

How can I remove an Item from an ArrayList given the itemNum?

I want to remove the Item given the ItemNo that the user will enter. how do I check if there exists an item with this itemNo first? and how would I then remove it? Below is what I have so far, do I ...
helloworld's user avatar
9 votes
4 answers
10k views

Remove an object from an ArrayList given only one attribute

I have an ArrayList of Items and I want to be able remove one Item from the list by entering only one Item attribute, for example its number (int ItemNumber). I also wanna do the same when I check ...
helloworld's user avatar
1 vote
3 answers
2k views

How to fix incompatible types with array of objects in list

I have a problem with the code below. Compiler says incompatible types, java.lang.object[][] required but found java.lang.object[]. Anyone have an idea why this is? I've found some about generics ...
Arto Uusikangas's user avatar