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 8586535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:19:58+00:00 2026-06-11T22:19:58+00:00

i am having this error java.lang.ClassCastException: [Ljava.lang.Object; in drawing a route from list of

  • 0

i am having this error java.lang.ClassCastException: [Ljava.lang.Object; in drawing a route from list of point
here is my drawing code

public class MyOverlay extends Overlay{

List<Double> location;
List<Double> lt;
List<Double> ln;
MapView mapView ;

Double[]lat;
Double[]lon;



public MyOverlay(List<Double> location, List<Double> lt, List<Double> ln, MapView mapView) {
    // TODO Auto-generated constructor stub
    this.location = location;
    this.mapView = mapView;
    this.ln =ln;
    this.lt = lt;
}


@Override
public void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow) {
    super.draw(canvas, mapView, false);

    lat = (Double[])lt.toArray();

    lon = (Double[]) ln.toArray();
    Path path1 = new Path();
    Point p1 = new Point();
    Path path2 = new Path();
    Point p2 = new Point();
    Point p3 = new Point();
    Point p4 = new Point();

    Projection projection = mapView.getProjection();
    int a = lat.length;
    int b = lon.length;
    int sum = a+b;

     Paint paint = new Paint();
     paint.setAntiAlias(true);
     paint.setColor(Color.RED);
     paint.setStyle(Paint.Style.STROKE);
     paint.setStrokeWidth(5);
     paint.setAlpha(90);

        Path p = new Path();
        Point from = new Point();
        Point to = new Point();
        for (int i = 1; i < sum; i++)
        {
            if (i == sum - 1)
            {
                break;
            }

        GeoPoint point1 =  new GeoPoint((int)(lat[i]*1E6) , (int)(lon[i]*1E6));
     (int)(Double.valueOf(lon[i+1])*1E6));
        projection.toPixels( point1, from);
        //projection.toPixels(point2, to);
        if(i ==1)
        {
        p.moveTo(from.x, from.y);
        }
        else
        {
             p.lineTo(to.x, to.y);
        }


        canvas.drawPath(p, paint);



}

}
tell me what i am doing wrong?

  • 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-11T22:19:59+00:00Added an answer on June 11, 2026 at 10:19 pm

    List.toArray() returns an array of Objects: Object[]. And an Object[] can’t be cast to a Double[].

    You should use

    lat = lt.toArray(new Double[lt.size()]);
    

    which returns a Double[]. See the javadoc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem where I receive this error: Exception in thread main java.lang.NullPointerException
I'm having this error in eclipes java.lang.UnsupportedClassVersionError: Bad version number in .class file .
I am having this error in my j2ee web application. java.sql.SQLException: ORA-00604: error occurred
I'm having this error page in Django. Exception Type: IndexError Exception Value: list index
I've having this problem with some JavaScript code. I've simplified it in the error
I'm having this problem where I keep getting this error in my console: *
I`m having the following error . Why am I having this error and how
having sorted this error - Ruby mysql2 Error I now am recieving this error
I am having this bizarre error and I don't know what to do. This
I'm having this WEIRD Xcode error - Uncategorized error. It seems to look for

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.