Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-07-2008, 01:23 AM
Member
 
Join Date: Jan 2008
Posts: 12
rhm54 is on a distinguished road
Type Casting Help
I believe this is a problem with Type casting but I am not sure. I have a LinkedList class that I have created which stores nodes of type Object. I am building a print queue that uses the list and stores an Object of type printdata in the nodes. This line of code here gives me the following error message:

Type mismatch: cannot convert from Object to PriorityQ.printdata

printdata temp = L1.getNode(0);

I assume that I need to type cast but I don't know how.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-07-2008, 02:52 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
stores an Object of type printdata
Try declaring/adding this "printdata" as the type instead of Object.
Code:
LinkedList<printdata> list = ...
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-07-2008, 02:06 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Casting
Hello rhm54

Try the following cast:
Code:
printdata temp = (printdata) L1.getNode(0);
I hope this does the trick.
__________________
If your ship has not come in yet then build a lighthouse.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Casting an int value into a char kurtulas New To Java 2 02-16-2008 10:03 PM
'Casting' couch !!!! ajaygargnsit Advanced Java 4 01-04-2008 06:54 PM
'Casting' couch !! ajaygargnsit New To Java 1 12-22-2007 03:05 PM
Casting leebee New To Java 5 08-10-2007 02:24 PM
The return type Marcus New To Java 1 07-05-2007 08:28 AM


All times are GMT +3. The time now is 04:49 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org