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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:59:28+00:00 2026-06-03T16:59:28+00:00

This is my method public AuctionItem[] getOpenAuctions() throws RemoteException { return itemList.toArray((AuctionItem[]) java.lang.reflect.Array .newInstance(itemList.getClass(),

  • 0

This is my method

public AuctionItem[] getOpenAuctions() throws RemoteException {

    return itemList.toArray((AuctionItem[]) java.lang.reflect.Array
            .newInstance(itemList.getClass(), itemList.size()));

}

and this is my error

Exception in thread "main" java.lang.ClassCastException: [Ljava.util.LinkedList; cannot be cast to [LAuction.AuctionItem;
at Auction.AuctionImpl.getOpenAuctions(AuctionImpl.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at $Proxy0.getOpenAuctions(Unknown Source)
at Seller.SellerMain.main(SellerMain.java:38)

What’s wrong with it?

  • 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-03T16:59:30+00:00Added an answer on June 3, 2026 at 4:59 pm

    Try:

    return itemList.toArray(new AuctionItem[itemList.size()]);
    

    The problem with the code you wrote is that itemList.getClass() returns the class LinkedList. So the Array.newInstance() method is creating a LinkedList[], which you are then trying to typecast to an AuctionItem[]. Since these two types are incompatible for assignment, it throws a ClassCastException.

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

Sidebar

Related Questions

Having this method: public Boolean isCorrect() { return correct; } I can't write: @XmlType(propOrder
when using this method public List<Field> getFieldWithoutId(List<Integer> idSections) throws Exception { try { Connection
I have this method: public static Expression<Func<MyEntity, bool>> MyMethod(string someId) { return o =>
I defined this simple method: public static boolean isBorder(int x, int y) throws CollisionDetectionException
I have this method public Expression<Func<Auction, bool>> GetUnsetDatesAuctionsExpression() { if (condition) return GetAllUnsetDatesAuctionsExpression(); else
I have this method : public function getInstance() { $classname = $this->getFullyQualifiedClassName(); return new
I wrote this method: public def getXScaleFactor(panelWidth: Int): Double = { return (panelWidth /
Why does this method (test) need a return value (it is always true)? public
This is the java main() method: public static void main(String[] args) { HashSet set
I'm loading an XML file with this method: public static String readTextFile(String fullPathFilename) throws

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.