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

  • SEARCH
  • Home
  • 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 8376107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:20:56+00:00 2026-06-09T15:20:56+00:00

I have a map with strings and tupleList. i am trying to get the

  • 0

I have a map with strings and tupleList.
i am trying to get the tupleList into double array , but i am getting type cast exception.
my code is —

Map<String, TupleList> results = null; -- Some data in it and TupleList has int or double value.

public void drawGraph(){

    Object[] test = new Object[results.size()];
    int index = 0;
    for (Entry<String, TupleList> mapEntry : results.entrySet()) {
        test[index] = mapEntry.getValue();
        index++;
    }


       BarChart chart = new BarChart();
        chart.setSampleCount(4);
        String[] values = new String[test.length];
        for(int i = 0; i < test.length; i++)
        {
            values[i] = (String) test[i];


        }
       //  double[] values = new double[] {32,32,65,65};
         String[] sampleLabels = new String[] {"deny\nstatus", "TCP\nrequest", "UPD\nrequest", "ICMP\nrequest"};
         String[] barLabels = new String[] {"STATUS", "TCP", "UDP", "PING"};

         //chart.setSampleValues(0, values);
         chart.setSampleColor(0, new Color(0xFFA000));
         chart.setRange(0, 88);
         chart.setFont("rangeLabelFont", new Font("Arial", Font.BOLD, 13));

error—-

java.lang.ClassCastException: somePackagename.datamodel.TupleList cannot be cast to java.lang.String
at com.ibm.biginsights.ExampleAPI.drawGraph(ExampleAPI.java:177)
at com.ibm.biginsights.ExampleAPI.main(ExampleAPI.java:95)

i am getting exception @

  String[] values = new String[test.length];
        for(int i = 0; i < test.length; i++)
        {
            values[i] = (String) test[i];

Thanks

  • 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-06-09T15:20:57+00:00Added an answer on June 9, 2026 at 3:20 pm

    I am assuming that the error is taking place here: values[i] = (String) test[i];. The problem is that you are trying to throw an object of type TupleList into a string. What you need to do, is to call the .toString() method, that should give you a string representation of the object.

    Note however, you will have to override the toString() method within the TupleList class so that you can get a string representation of the object which suits your needs.

    So in short, just doing test[i].toString() will most likely yield something along the lines of this: TupleList@122545. What you need to do is this:

    public class TupleList
    ...
    
    @Override
    public String toString()
    {
        return "...";
    }
    
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of strings which need to be taken into a map.
I have an array of strings like this: tableArray: { Map, Web, Help +
I have map of string and array of strings as: private static Map cacheTimeStamp
in my action class i want to have a map of strings. and in
I have Java Map (out of Strings and Ints) objects that I want to
Possible Duplicate: remove_if equivalent for std::map I have a set of strings: set <wstring>
I have this as a return type in Scala Map[String, Seq[Map[String, Seq[MyClass]]]] I have
I have a Hashtable that maps strings to ints. Strings are unique, but several
I have this array of strings private static String[] colorsArray = { #bde876, #ff8581,
I have a class which contains a static member, a map of strings to

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.