classcastexception Questions

3

Solved

UPDATE - To make the question clearer. What is the possible cause of getting a ClassCastException while calling a method via reflections? I got the following stacktrace as a part of my applicatio...

4

Solved

This is an interview question. The interview is over, but this question is still on my mind. I can't ask the interviewer, as I did not get the job. Scenario: put object of class C1 in to a c...
Scan asked 18/4, 2013 at 20:8

3

Solved

Code: public class CompareTest { public static void main(String[] args) { ArrayList list = new ArrayList(); (list).add(new CompareTest()); Arrays.sort(list.toArray()); //Does not throw Ex...
Capo asked 16/3, 2013 at 14:22

3

Solved

I have a number (power(2,k)) of BitSet objects and I want to store them in a SortedSet. I use the code: Set <BitSet> S= new TreeSet<>(); However, I am getting this error: java.lang.C...
Windflower asked 11/3, 2013 at 2:37

1

Solved

The root of my problem is that I have a method that handles JDBC queries and releases all connections after the query. A "ResultSet" is passed back to the calling method. I have found that I can'...
Ringworm asked 27/2, 2013 at 22:10

3

Solved

So, I'm working in Java, Trying to cast a java.sql.ResultSet to my own class MyResultSet Here is the code: MyResultSet.java public class MyResultSet implements java.sql.ResultSet{ //There are a ...
Louvain asked 19/2, 2013 at 17:29

3

Solved

I'm trying to "animate" a WebView to drop down and reveal its contents. I've written a handler to increase the height by 1 each time, however, I'm running into a ClassCastException. The code I'm u...
Philander asked 24/2, 2011 at 4:53

2

Solved

I am getting a strange behavior, and I guess I'm more looking for an explanation than a solution (although solution is welcome as well!). Here's the code: PackageManager pm = context.getPackageMa...
Essieessinger asked 22/10, 2012 at 21:25

4

Solved

Ok, I'm new to android development and am trying to bind to a service so that I can call methods on the service once it's been started. The Activity and Service described below are both part of the...
Unavailing asked 7/11, 2011 at 17:31

3

Solved

I have been trying to do a little project that needs an appendable ObjectOutputStream. I have gone through a couple of solutions and i found this It seemed to solve my problem at first. But on furt...
Lasky asked 5/9, 2012 at 10:19

2

Solved

Language: Java Compiler version: 1.6 In the below code, am trying to do the following: create a List<String> add a String assign List<String> to raw List create a List<Integer>...
Inexpiable asked 9/9, 2012 at 15:1

1

Solved

I am getting a class cast exception with hibernate when trying to cast the result set to the mapping class... I am able to see the data in the result set that is returned...however it comes back as...
Excoriate asked 25/5, 2012 at 12:51

4

I tried different ways to fix this, but I am not able to fix it. I am trying to get the Boolean value of an Object passed inside this method of a checkBox: public boolean onPreferenceChange(Prefer...
Prospector asked 17/5, 2012 at 20:3

1

Solved

I'm getting a class cast exception namely java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.GDApplication when I'm trying to use the green droid library in my...
Signatory asked 23/3, 2012 at 5:8

2

Solved

Here is my stripped down class and enum. class A { @Enumerated (value = EnumType.STRING) AType type; } enum AType { X,Y } if I run query = FROM A a WHERE a.type = :type query.setParameter(...
Surfacetosurface asked 22/2, 2011 at 21:1

3

Solved

I'm obtaining a Vector from a product's API. Vector<?> dataVector = dataAPI.getReturnVector(); The vector is expected to contain Strings as value. I'm able to print the size of the vector ...
Underwrite asked 1/2, 2012 at 15:45

3

Solved

I'm using java generics and varargs. If I use the following code, I'll get a ClassCastException, even though I'm not using casts at all. Stranger yet, if I run this on Android (dalvik) no stack t...
Trudietrudnak asked 29/1, 2012 at 23:57

2

Using eclipse and the Android SDK, I managed a simple test app with a Button and a ProgressBar. All runs fine, except I did't want the ProgressBar to move the Button, when the ProgressBar was made ...
Scad asked 6/1, 2012 at 13:59

10

Solved

I called a getElements method which returns Iterable<Element>. I did this: List<Element> elements = (List<Element>) getElements(); This generates the error: java.lang.ClassCa...
Townscape asked 18/10, 2010 at 13:55

4

Solved

I've got a little problem where I can't find the mistake I am making, it's probably something really simple. I've got the following layout <?xml version="1.0" encoding="utf-8"?> <Relativ...
Adventuresome asked 23/11, 2011 at 9:16

1

I am just playing with MessageFormat but when I try to pass a String to MessageFormat format method it compiles fine but then I get a runtime classcast exception. Here is the code. MessageFormat f...
Assign asked 31/5, 2011 at 15:3

1

Solved

I have the following code IJavaProject targetProject = null; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); for (IProject project : root.getProjects()) { if (project.getName()...

3

I have a method which has a list of inputs and each input value I have to cast it to required type. (Actually this list has values of parameters in "some" form which I am supposed to converted into...
Pneumato asked 8/7, 2011 at 11:44

1

Solved

I have the following code within a program I'm making: 01 public class Clazz<T> 02 { 03 T[] t; 04 05 public Clazz<T> methodA(int... ints) 06 { 07 Clazz<Integer> ints2 = new Claz...
Unseam asked 30/6, 2011 at 16:32

2

Solved

Is there Scala equivalent of C# as keyword? var something = obj as MyClass; Scala's asInstanceOf throws java.lang.ClassCastException: val something = obj.asInstanceOf[MyClass]
Tunicle asked 23/6, 2011 at 9:14

© 2022 - 2024 — McMap. All rights reserved.