Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1055397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:33:22+00:00 2026-05-16T17:33:22+00:00

I have an object in my code of the type Object: Object o The

  • 0

I have an object in my code of the type Object:
Object o

The class of the instance is Object: o.getClass() gives Object.

Now, it should be a Map! How can I upcast this to a Map?

I tried: Map<String, Object> map = (HashMap<String,Object>)o

But this returns:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.util.HashMap

The instance ‘o’ comes from a XMLRPC request. This request does not qualify variables correctly supposedly

Please have a look at this!?

EDIT:

Now I have the following issue:
o.getClass().getName() gives java.util.ArrayList,

o.get(0) gives [Ljava.lang.Object;@739e8329,

and o.get(0).getClass().getName() gives java.lang.String.

I cannot findout what to do..

EDIT2:

Finally I found out what happened. The software that created this object flattened a datastructure into a String (valueOf()). So, when I printed the variable it returned a [Ljava.util.Object, which was in fact a String containing this information.

Thanks guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:33:23+00:00Added an answer on May 16, 2026 at 5:33 pm

    [Ljava.lang.Object indicates the type of the object o is an array of Objects – that is Object[]. You cannot cast it to Map.

    You might find it useful if took a look at: java: what is this: [Ljava.lang.Object;?

    You stated that .getClass() indicated Object, but was it Object or [LObject?
    Compare to:

        Object[] array= new Object[]{};
        Object simple = new Object();
    
        System.out.println(array.getClass());
        System.out.println(simple.getClass());      
    

    which prints:

    class [Ljava.lang.Object;
    class java.lang.Object
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can you write object oriented code in C? Hi! Just for the
Possible Duplicate: How to have Moose return a child class instance instead of its
I have a method on one of my objects that returns a new instance
In my C# app I have an object with for eg. properties Color and
The code below works for the class that I hard coded XCCustomers in my
Several of my modules contain global class instances that implement a given class type
My starting point is the following: - I have a method, transform, which I
I have a question about inner-workings of Python sub-interpreter initialization (from Python/C API) and
Hallo, I have a quite strange problem in one of my C++ projects: I
I am trying to use WPF printing from PowerShell. I have found a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.