why do i get this exception?
Map myHash = null
myHash = (HashMap)Collections.synchronizedMap(new HashMap());
If i try to use this hashmap, i get java.lang.ClassCastException
public class A { }
public class B:A { }
void foo()
{
A a = new B();
B b = a as B;
}
for a given instance setup, will lock(a) be equivalent to lock(b) ?
I have a derived class that's a very thin wrapper around a base class. Basically, I have a class that has two ways that it can be compared depending on how you interpret it so I created a new class that derives from the base class and only has new constructors (that just delegate to the base class) and a new operator==. What I'd like to do is…
I think I have a pretty simple problem that is just pretty difficult to word and therefore hard to find a solution for. Setup:
PathCollection is a Backbone.Collection of Paths
Path is a Backbone.Model which contains NodeCollection (which is a Backbone.Collection) and EdgeCollection (which is a Backbone.Collection).
When I fetch…
two clients communicate to each other on top of a message layer
in the message body, I need include a field pointing to any data type
From client A, I send the field as a shared_ptr to the message layer.
I define this field as a shared_ptr in the message layer.
But how can I convert this field back to shared_ptr in client B?
Or…
Is there a way to do the below? Imagine a generic result wrapper class. Where you have a type and an associated error list. When there is no result to return to the user we will use boolean to indicate success failure. I want to create a constructor that takes in an error list, and if the list is null or count 0, AND the type…
Let's say we have 2 classes A and B
public class A{
private int member1;
A() {
member1 = 10;
}
public getMember(){
return member1;
}
}
Class B is also on the same lines except that its member variable is named member2 and gets intitialized to say 20 inside the constructor.
My Requirement :
At runtime , I get a string…
I'm having problems when using linq on a datatable.asenumerable().
This throws InvalidCastException.
DateTime date=r.Field<DateTime>("date");
This works fine.
DateTime date = DateTime.Parse(r.Field<string>("date"));
What am I missing?
Regards Sven
I am building a helper object that has a property called Mailer. In reality Mailer can be either a System.Net.Mail.MailMessage or a Mono.System.Net.Mail.MailMessage. So I would preferably only want 1 declaration of mailer.
For example I don't want:
private Mono.Mailing.MailMessage MonoMessage = new…
I have a class Application that I need to override with INotifyPropertyChanged events. I have written the logic to override the original class and ended up creating SuperApplication
I am pulling the data from a library though, and cannot change the loading logic. I just need a way to get the data…
This is my second post. After learning from my first post how fantastic is to use Linq to SQL, I wanted to try to import data from a Excel sheet into my SQL database.
First My Excel Sheet:
it contains 4 columns namely
ItemNo
ItemSize
ItemPrice
UnitsSold
I have a created a database table…
I am trying to implement a ListSelectionListener for some of my JTables. Simply (at the moment) the ListSelectionListener is supposed to simply return the text of the cell that was selected.
My program design has several JTables and I would like to have one ListSelectionListener work for them all.…
In R, I have a data frame with columns for Seat (factor), Party (factor) and Votes (numeric). I want to create a summary data frame with columns for Seat, Winning party, and Vote share. For example, from the data frame
df <- data.frame(party=rep(c('Lab','C','LD'),times=4),
…
From what I understand, PHP objects are generally much faster than arrays. How is that efficiency affected if I'm typecasting to define stdClass objects on the fly:
$var = (object)array('one' => 1, 'two' => 2);
If the code doing this is deeply-nested, will I be better off explicitly…
I have the following code:
Double i=17.31;
long j=(long) (i*100);
System.out.println(j);
O/P : 1730 //Expected:1731
Double i=17.33;
long j=(long) (i*100);
System.out.println(j);
O/P : 1732 //Expected:1733
Double i=17.32;
long j=(long) (i*100);
System.out.println(j);
O/P : 1732 …
I know this is probably a dupe, but I can't for the life of me remember what the name is or even how to look it up.
I know T would the the Type you are casting to, but what is the technical name of it.
NavigatorItem NavItem = (NavigatorItem)cboItems.SelectedItem;
lblTitle.Text = NavItem.Title;
RadWrapPanel Panel = new RadWrapPanel();
Type t = NavItem.ItemsType; //<------ The Type inside my List is here.
List<???> items =…
Most of the time, I am doing this way.
class a {
public:
~ a() {
i = 100; // OK
delete (int *)j; // Compiler happy. But, is it safe?
// Error : delete j;
}
private:
volatile int i;
volatile int *j;…
#include<stdio.h>
/* this is a lexer which recognizes constants , variables ,symbols, identifiers , functions , comments and also header files . It stores the lexemes in 3 different files . One file contains all the headers and the comments . Another file will…
Well, the WinAPI has a POINT struct, but I am trying to make an alternative class to this so you can set the values of x and y from a constructor.
/**
* X-Y coordinates
*/
class Point {
public:
int X, Y;
Point(void) : X(0), Y(0) {}
…
Is there a way to pass a wrap and unwrap a TObject descendent in an OleVariant? I am trying to pass a TObject across automation objects. I know it's not a good idea but I don't have a good alternative.
Something like this:
function GetMyObjAsVariant;
var
…
I have an asp.net page with a code-behind class definition as follows:
public partial class examplepage : System.Web.UI.Page
I'd like to set a public property within the page that I can reference from other classes. My understanding is that if I cast to…
On Button Click
Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
MsgBox("INSIDE")
If SocialAuthUser.IsLoggedIn Then
Dim accountId As Integer = BLL.getAccIDFromSocialAuthSession
…
If I have the enum:
public enum VehicleType
{
Car = 0,
Boat = 1,
Bike = 2,
Spaceship = 3
}
and I then do:
int X = 10;
VehicleType vt = (VehicleType)2;
X = X + vt;
Console.WriteLine("I travel in a " + vt + " with " + X + " people.");
…
I have a member variable of type vector (where is T is a custom class, but it could be int as well.)
I have a function from which I want to return a pointer to this vector, but I don't want the caller to be able to change the vector or it's items. So I…