classcastexception Questions

3

Solved

@Override public void onPause() { super.onPause(); save(notes.itemSelected); } @Override public void onResume() { super.onResume(); notes.itemSelected.clear(); notes.itemSelected = load(); } ...

2

Solved

I am trying to read an ASN1 object using Bouncycastle on Android. I expect it to be a DERSequence, which in Bouncycastle is a subclass of ASN1Sequence, which is a subclass of ASN1Object. import or...
Marlo asked 12/4, 2011 at 11:33

4

Solved

I have implemented this function: static <X,Y> Y castOrNull(X obj) { try { return (Y)obj; } catch(ClassCastException e) { return null; } } This gives me the compiler warning: Type...
Chayachayote asked 14/10, 2010 at 13:27

2

Solved

I have a Java EE application and I use Hibernate. The domain objects, I changed the List / ArrayList to Set / HashSet, because it is better to use Sets. But in my Dao implementation I run into a p...
Urinary asked 12/10, 2010 at 11:59

4

Solved

In what circumstances can ClassCastException occur in the code below: import java.util.Arrays; import java.util.List; public class Generics { static List getObjects() { return Arrays.asList(1,...
Berserk asked 7/10, 2010 at 11:6

4

Solved

public class Empty { public static void main( String[] args ) { TreeSet<Class> classes = new TreeSet<Class>(); classes.add( String.class ); String test = new String(); try{ i...
Relational asked 17/8, 2010 at 11:41

3

Solved

List<MyClass> myclassList = (List<MyClass>) rs.get(); TreeSet<MyClass> myclassSet = new TreeSet<MyClass>(myclassList); I don't understand why this code generates this: j...
Adrianaadriane asked 24/3, 2010 at 1:32

3

I have a preferences.xml that looks like this: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <EditTextPrefer...
Hi asked 16/3, 2010 at 18:54

1

I am reading about Java Generics and I came across this topic where I am a bit confused. From : http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ205 public abstract...
Racialism asked 24/12, 2009 at 12:31

4

Solved

Since generics are only checked during compile time with Java 5, can they avoid ClassCastExceptions in all situations?
Medallion asked 14/8, 2009 at 10:56

3

Solved

I think there must be something subtle going on here that I don't know about. Consider the following: public class Foo<T> { private T[] a = (T[]) new Object[5]; public Foo() { // Add som...
Gambill asked 16/12, 2008 at 18:42

© 2022 - 2024 — McMap. All rights reserved.